Dev1ce
Dev1ce

Reputation: 5944

NodeJs async.waterfall task.apply is not a function

I am trying to learn NodeJs's async library,
I created 3 functions and pushed them into an array,
the array is then passed to the async.waterfall function,

But I get the following error -
enter image description here

Following is my code -

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

Upvotes: 0

Views: 171

Answers (1)

liny
liny

Reputation: 26

[waterfallFunctionArray] == [[]]

Upvotes: 1

Related Questions