How can I handle two one async.each into async.waterfall....Cannot read property 'bodyClass' of undefined


  • GNU/Linux

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

  • Admin

    Is this for a hook of some sort? Please paste the entire function, and which hook you're subscribing to...



  • This post is deleted!

Log in to reply
 

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.