How can I handle two one async.each into async.waterfall....Cannot read property 'bodyClass' of undefined
-
I have this code:
var array=[]; async.waterfall([ function(called) { var array=[]; //Suppose to have another array that have some values called total async.forEach(total,function(item,callback){ array= array.concat(item); callback(); },function(error){ called(null,array); //but i Obtain this error Cannot read property 'bodyClass' of undefined }); }],function(err,elem){ }); If there are some syntax error doesn't matter. Anyone can help me? });
-
I have no idea where bodyClass comes into play, but maybe this will help:
var async = require('async'); var total = ['a', 'b']; async.waterfall([function(called) { var arr = [1, 2]; async.forEach(total, function(item, callback) { arr = arr.concat(item); callback(); }, function(error) { called(null, arr); }); }], function(err, elem) { console.log(err, elem); // Output: null [ 1, 2, 'a', 'b' ] });
Copyright © 2024 NodeBB | Contributors