Answer the question
In order to leave comments, you need to log in
async node.js not working?
There is such a function
getBalance = function(id) {
connection.query('SELECT balance FROM Users WHERE id = ?', id, function(error, result, fields) {
if(error)
return error;
if(result[0]['balance'])
return result[0]['balance'];
return 0;
});
};
var a = async.parallel(getBalance(123123), function(err, callback){
if (err) throw err;
return callback;
});
console.log(a);
Answer the question
In order to leave comments, you need to log in
async.parallel([getBalance(123123)], function(err, result){
if (err) return next(err); //<- custom error handler
// do result;
console.log(result);
});
var getBalance = (callback) => {
connection.query('SELECT balance FROM Users WHERE id = ?', id, (error, result, fields) => {
if(error)
return callback(error);
if(result[0]['balance'])
callback(null, result[0]['balance']);
});
callback(null, 0);
}
;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question