title: How can I fetch an array of URLs with Promise.all?
body: <p>If I have an array of urls:</p>
  
  <pre><code>var urls = ['1.txt', '2.txt', '3.txt']; // these text files contain "one", "two", "three", respectively.
  </code></pre>
  
  <p>And I want to build an object that looks like this:</p>
  
  <pre><code>var text = ['one', 'two', 'three'];
  </code></pre>
  
  <p>I’ve been trying to learn to do this with <code>fetch</code>, which of course returns <code>Promise</code>s.  </p>
  
  <p>Some things I’ve tried that <em>don’t</em> work:</p>
  
  <pre><code>var promises = urls.map(url =&gt; fetch(url));
  var texts = [];
  Promise.all(promises)
    .then(results =&gt; {
       results.forEach(result =&gt; result.text()).then(t =&gt; texts.push(t))
    })
  </code></pre>
  
  <p>This doesn’t look right, and in any case it doesn’t work — I don’t end up with an array ['one', 'two', 'three'].</p>
  
  <p>Is using <code>Promise.all</code> the right approach here? </p>