Q Promise Nodejs how to resolve in loop
i have code written in nodejs make me confusying using Q Promises theFunction() .then(function(data) { var deferred = Q.defer() var result = []; for(i=0; i < data.length; i++) { secondFunc(data.item) .then(function(data2) { data.more = data2.item }); result.push(data); } deferred.resolve(result); deferred.promise(); }); i want data in second function inside loop can push into result so my previous data is like this [ { id: 1, item: 1, hero: 2 }, { id: 1, item: 1, hero: 2 } ] and so like this [ { id: 1, item: 1, hero: 2, more: { list: 1 } }, { id: 1, item: 1, hero: 2, more: { list: 4 } } ] I've