title: Why are promises resolved before executing Promise.all()?
body: <p>in a node.js program I need to call an API with a POST request after collecting some depending data asynchronously.</p>
  <p>The code structure looks basically like this:</p>
  <pre><code>var promises = [];
  for(n records in parentRecord.children) { 
     promises.push( 
       getDetails().then( 
         getDetailsOfDetails().then ( 
            httpRequest(&quot;POST&quot;, collectedData).then(
              updateRecord(withNewId)
            )
         )
      )
    );
  }
  
  result = Promise.all(promises).then( updateParentRecord(withCollectedResults from HTTP responses) );
  </code></pre>
  <p>The problem is that everything starting with <code>getDetails()</code> is executed twice, so that n*2 http requests are sent.
  As you may see from the structure, I am not an expert in promises.
  How can the code be restructured so that the promises are resolved only once when Promise.all is resolved?</p>