“callback不是一个函数”Node.Js

我有一个使用mysql,async.waterfall在NodeJs中编写的项目

我也实施了async.waterfall,以避免我最近的问题,“callback不是一个函数”

但问题依然存在。

这是我的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); }); }); } 

我非常接近完成我的项目,但那个错误让我感到沮丧。 请有人帮助我。

你似乎在呼唤

 hold.getVoterCount(id, json, function(votercount){ if(votercount == 0){ } else { console.log('last function'); } }); 

但是你的getVoterCount函数只有2个预期的参数。 我build议尝试只传入2个参数:

 hold.getVoterCount(id, function(votercount){ if(votercount == 0){ } else { console.log('last function'); } });