i'm trying return data to view from multiple selects and i'm using the async.parallel
but in console show me Promise {<pending>}
.
I require the var async = require('async');
This is the first time that i try use it, what i'm doing wrong?
new(req, res)
{
async.parallel(
{
one: function(callback) {
callback(null, request.query("SELECT * FROM table1 where ref like '90%'"));
},
two: function(callback) {
callback(null, request.query("SELECT * FROM table2 where ref like 'K%'"));
}
}, function(err, results)
{
console.log("RESULT:");
console.log(err);
return res.render('view-1', {"one": results.one, "two": results.two});
});
}
Thank you
Shot in the dark: Try to change from callbacks to Promises
The Promise.all's then will only be fired if both queries are successfull and the list of the results will be in the same order as the queries.
If you're not using ES6 then you can import Promise like this