Recently i tried using this waterfall method in my mongoose but unfortunately it throwed error,which i am not able to figure out can anyone suggest me help.......
TypeError: callback is not a function
My code,
exports.waterfall = function (err, res) {
async.waterfall([
function (callback) {
var item = {
'status': '1',
'type': 'categories'
};
Categories.find(item, function (err, result) {
if (err) {
return
}
if (result) {
callback(null, result)
}
});
},
function (sol,callback) {
var response = [];
for (var i in sol) {
var id = sol[0]._id,
item = {
'categoryid': id,
'status': '1',
'type': 'topics'
};
Categories.find(item, function (err, soll) {
if (err) {
return
}
if (soll) {
console.log(soll)
}
});
}
callback(null,soll)
}
],
function (err, ress) {
if(err){
console.log('err')
return
}
if(res){
res.json(ress)
}
});
};
Recently i tried using this waterfall method in my mongoose but unfortunately it throwed error,which i am not able to figure out can anyone suggest me help.......
function (callback, sol) {
Should be function (sol, callback)
, the callback is always the last argument.