title: How do i make javascript loop wait for each iteration of loop to finish before starting the next?
body: <p>I have a loop that gets iterated through 1000 times where each iteration makes a request and then prints the result of that request.</p>
  <p>Similar to below.</p>
  <pre><code>let start = console.log(Date.now())
  for (i = 0; i &lt; 1000; i++) {
      request.then(data =&gt; {
          console.log(Date.now() - start)
      })
  }
  </code></pre>
  <p>This however results in the first request taking much longer to be completed then if there was just 1 iteration of the loop.</p>
  <p>with i &lt; 1000:</p>
  <pre><code>5860
  ...
  </code></pre>
  <p>with i &lt; 1:</p>
  <pre><code>220,
  ...
  </code></pre>
  <p>For the aim of this script however, I want to wait for each result to be received before starting the next iteration of the loop.</p>