title: Q Promise Nodejs how to resolve in loop
body: <p>i have code written in nodejs make me confusying using <code>Q Promises</code></p>
  
  <pre><code>theFunction()
  .then(function(data) {
      var deferred = Q.defer()
      var result = [];
      for(i=0; i &lt; data.length; i++) {
  
          secondFunc(data.item)
          .then(function(data2) {
              data.more = data2.item
          });
          result.push(data);
  
      }
  
      deferred.resolve(result);
      deferred.promise();
  
  });
  </code></pre>
  
  <p>i want data in second function inside loop can push into result</p>
  
  <p>so my previous data is like this</p>
  
  <pre><code>[
      {
          id: 1,
          item: 1,
          hero: 2
      },
      {
          id: 1,
          item: 1,
          hero: 2
      }
  ]
  </code></pre>
  
  <p>and so like this</p>
  
  <pre><code>[
      {
          id: 1,
          item: 1,
          hero: 2,
          more: {
              list: 1
          }
      },
      {
          id: 1,
          item: 1,
          hero: 2,
          more: {
              list: 4
          }
  
      }
  ]
  </code></pre>
  
  <p>I've tried several ways start by entering the command 
  deferred.resolve (); statement in the loop and only showing 1 data
  have any solution ?</p>