In my NodeJS backend I have a function where I get a value from the sqlite database and I want to send it to the frontend but it always says Object { msg: false }
i think I need a function where I can make a synchronous call of the functions.
My Code:
router.get('/', function(req, res, err){
var msg = " ";
var uid = req.session.user;
function printMsg(message){
msg = message;
}
db.getMsg(uid, printMsg);
if(err){
res.send({msg : "No message available"});
} else{
res.send({msg: msg})
}
});
Can anyone help me? Thanks in advance.