I have declared variable globally at top of the variable and I am trying to access it inside the other call to do check whether user_id exist or what?. My function is working properly, but it's failing to validate. Please let me know where I am going wrong.
Global Method :
function isUserExist(user_id,callback) {
db.query('select id from user where id = ?' , [user_id],function(error, rows) {
console.log("i ------>" + user_id);
if(rows.length >0) {
return true;
}else {
return false;
}
});
}
inside another method :
router.post('/addcustomerasset', function(req,res) {
if (create(user_id) ){
console.log("User exists");
// Code will execute
}
else{
response.success = false,
response.mssg = "User Doesn't Exist";
res.json(response);
}
});