1
我写了与MySQL的NodeJS项目,async.waterfall“回调不是一个函数”的node.js
我也实施了async.waterfall避免我最近的问题有关“回调不是一个函数'
但问题仍然存在。
这里是我的async.waterfall
async.waterfall([
function (callback) {
hold.getEntry(function(data){
var ref = data.ref;
id = data.id;
var message = data.mess;
json = JSON.parse(message);
return callback(null, {'ref':ref, 'id':id, 'json':json});
});
},
function (dataa, callback) {
if(dataa.ref === null){
callback(null);
}else{
hold.checkPositionCandidate(dataa.ref, dataa.id, dataa.json, function(dataaa){
return callback(null, dataaa);
});
}
},
function(anoData, callback) {
console.log(anoData);
if(anoData === true){
//the err is here
hold.getVoterCount(id, json, function(votercount){
if(votercount == 0){
} else {
console.log('last function');
}
});
} else {
}
}
], function (err, results) {
// When finished execute this
});
,这是我getVotercount功能
function getVoterCount (id, callback){
pool.getConnection(function(err, con){
con.query("select total_voters as tv from pollwatcher_view where party_id = ?", [id], function(err, rows){
setTimeout(function(){
//this callback is not a function
callback(null, {'count':rows[0].tv});
console.log(rows);
}, 2000);
});
});
}
我很接近完成我的项目,但犯错让我挫败。请有人帮助我。
所以你调用带有三个参数... – elclanrs
功能...所以改变'hold.getVoterCount(ID,JSON,功能(votercount){ ...})''到'hold.getVoterCount(id,function(votercount){..})' –
@elclanrs是的,我有一个外部的json变量 – something