title: How to use `Array#map` within `Promise.all` in JavaScript
body: <p>I am trying to create a <code>Promise.all</code> with an array of items. So if I create it like this it works fine</p>
  
  <pre><code>Promise.all([
    Query.getStuff(items[0]),
    Query.getStuff(items[1])
  ]).then(result =&gt; console.log(result))
  </code></pre>
  
  <p>If I try to create the <code>Promise.all</code> like this, it doesn't work</p>
  
  <pre><code>Promise.all([
      items.map(item =&gt; Query.getStuff(item))
  ]).then(result =&gt; console.log(result))
  </code></pre>
  
  <p>The <code>then</code> block is run before the <code>Query.getStuff(item)</code>.  What am I missing?</p>