Because forEach
accept only one callback
. Since you are calling asynchronous method inside forEach
you need to check whether all asyn call completed
var response = [];
myArray.forEach(function(data, index) {
data.asyncFunction(function(result) {
response.push(result);
if(response.length === myArray.length) {
//foreach work done
}
});
});
No comments:
Post a Comment