title: Need delay in between POSTs in JavaScript loop iterations
body: <p>I have a json file and I am iterating over its contents and using a HTTP post request for each iteration. The POST request inserts info in a database. I need to introduce a delay either in the loop or somehow in between the POSTs. What I have now is this:</p>
  
  <pre><code>var request = require('request');
  
  for (i = 0; i &lt; arr.length; i++) {
      request.post(
          'http://localhost:3000/post',
          { form: { from: arr[i][0], to: arr[i][1]} },
          function (error, response, body) {
              if (!error &amp;&amp; response.statusCode == 200) {
                  console.log(body)
              }
          }
      );
  }
  </code></pre>
  
  <p>Currently, the POST requests are called pretty much instantaneously after one another, which poses a problem for some of the DB insertion logic that requires some time in between. Does anyone have a good idea as to how to implement a delay?</p>
  
  <p>Thank you</p>