The following is the output from my server.js file.
I am printing out the query string parameters that I'm passing into the stored procedure.
ID : 10################_
Email : [email protected]
Name : testname
FamilyName : testtesttest
Below this is the error I'm getting:
(node:8084) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'type' of undefined
(node:8084) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Below is my call to the stored procedure. I keep getting the above error and the stored procedure is not being executed. I've looked at the following link that appeared to have the same problem, but I'm still getting the same error.
This is my 1st attempt to call a stored procedure using this node module. So any assistance is appreciated.
app.get('/addRegistration', function(req,res){
try
{
const pool5 = new sql2.ConnectionPool(config, err =>
{
// Stored Procedure
pool5.request()
.input('FBID', sql2.varchar, 250, req.query.id)
.input('FBEmail', sql2.varchar, 250, req.query.email)
.input('FBName', sql2.varchar, 250, req.query.memberName)
.input('FamilyName', sql2.varchar, 250, req.query.familyName)
.execute('sp_registerUser', (err, result) =>
{
console.log("Success");
}).catch(function(err) {
console.log(err);
});
})
pool5.on('error', err => {
console.log("Error");
})
} catch (err) {
// ... error checks
console.log("addRegistration: " + err)
}
});
I found the issue. It was my original code.
.input('FBID', sql2.varchar, 250, req.query.id)
.input('FBEmail', sql2.varchar, 250, req.query.email)
.input('FBName', sql2.varchar, 250, req.query.memberName)
.input('FamilyName', sql2.varchar, 250, req.query.familyName)
Needed to be changed to:
.input('FBID', sql2.VarChar(250), req.query.id)
.input('FBEmail', sql2.VarChar(250), req.query.email)
.input('FBName', sql2.VarChar(250), req.query.memberName)
.input('FamilyName', sql2.VarChar(250), req.query.familyName)
Ultimately I had the size as part of the value parameter. It was all wrong. Once I did it correctly, then the stored procedure executed as expected.