I'm trying to return some rows from a db, connection works fine and everything but when express calls the function that retrieves the data it doesn't wait for the response.
I've tried many ways to write a callback to no avail, I've even tried using async (see code below), and it still runs all the way to the end before the data is even there. Any help?
router.get('/db/selectAllReadings', function(req, res) {
async.waterfall([
function(next){
console.log('function 1');
var rows = dbFunctions.selectAllReadings();
next(rows);
},
function(next, rows){
console.log('function 2');
console.log(rows);
next(rows);
},
function(next, rows){
console.log('function 3');
res.json(rows);
}
]);
});