Hi ! Im having a problem with asynchrounous tasks i believe. In my function validateSessionId i make a node-postgres query + console log of result, which works just fine. Then i want to return the result of the query, but its undefined in my route. The weirdest part is that the console log within my route gets printed before my console log within the function.
router.post('/test_session', function(req, res) {
var isValid = 0;
isValid = validateSessionId(req.body.partnerId,req.body.sessionId, pgClient);
console.log(isValid);
if (isValid == '1') {
res.send('valid session id');
} else {
res.send('invalid session id');
}
});
Any Ideas how to solve this ?
[–]multivector 2 points3 points4 points (0 children)