title: How to run fetch() in a loop?
body: <p>I am new to nodejs and promise based request. I want to fetch the data from a remote server in a loop, and then create a JSON object from all fetched data.</p>
  
  <pre><code>const fetch = require('node-fetch');
  const users = [];
  
  const ids = await fetch('https://remote-server.com/ids.json');
  console.log(ids);
  // [1,2,3]
  
  ids.forEach(id =&gt; {
      var user = await fetch(`https://remote-server.com/user/${id}.json`);
      users.push(user);
  });
  
  console.log(users);
  
  </code></pre>
  
  <p>expected output</p>
  
  <pre><code>    [
          {
              name: 'user 1',
              city: 'abc'
          },
          {
              name: 'user 2',
              city: 'pqr'
          },
          {
              name: 'user 3',
              city: 'xyz'
          }
      ]
  </code></pre>