NodeJs async.waterfall task.apply不是函数

时间:2018-10-22 06:41:50

标签: node.js async.js

我正在尝试学习NodeJs的异步库,
我创建了3个函数并将其推入数组,
然后将数组传递给async.waterfall函数,

但是出现以下错误-
enter image description here

以下是我的代码-

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);
});

1 个答案:

答案 0 :(得分:1)

[waterfallFunctionArray] == [[]]