我正在尝试学习NodeJs的异步库,
我创建了3个函数并将其推入数组,
然后将数组传递给async.waterfall函数,
但是出现以下错误-
以下是我的代码-
var async = require('async');
var waterfallFunctionArray = [];
var functionOne = function(callback) {
console.log("WATERFALL ONE");
callback(null, 1);
};
var functionTwo = function(param1, callback) {
console.log("WATERFALL TWO");
callback(null, param1+param1);
};
var functionThree = function(param2, callback) {
console.log("WATERFALL THREE");
callback(null, param2+1);
};
waterfallFunctionArray.push(functionOne);
waterfallFunctionArray.push(functionTwo);
waterfallFunctionArray.push(functionThree);
async.waterfall([waterfallFunctionArray], function (err, result) {
if (err) {
console.error(err);
return;
}
console.log("WATERFALL RESULT => \n"+result);
});
答案 0 :(得分:1)
[waterfallFunctionArray] == [[]]