I have code written in nodejs making me get confused 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 the data in the second function inside the loop to be able to insert the result
so my previous data is like this
[ { id: 1, item: 1, hero: 2 }, { id: 1, item: 1, hero: 2 } ]
and like it so much
[ { id: 1, item: 1, hero: 2, more: { list: 1 } }, { id: 1, item: 1, hero: 2, more: { list: 4 } } ]
I tried several ways to start by entering the Delayed Resource () command; operator in a loop and showing only 1 data is there any solution?
Nazril Faudi
source share