Monday, 13 March 2017

How to call recursive function after execute async.each

Anyone suggests me how can I trigger recursive function after executing the async.each.I have done the logic by following

function recursive(aggs, callback) {
async.each(datas, function(data, asynccallback) { 
    // after some process
    asynccallback(null, true); 
}, function(err, resultData) {
    //after execute the async.each I need to do the following
        if (resultData.flage) { 
            // flage true call recirsive 
            recursive(args, callback); 
        } else { 
            // flage flase means return the callback to called function
            callback(null, data) 
        }
});

}

When I try the above way I got

error: callback was already called.

Can anyone guide me to achieve this?.Thanks in Advance



via mohan

No comments:

Post a Comment