title: Making the while loop synchronous
body: <p>I've got a following piece of code</p>
  
  <pre><code>var page = 2;
  var last_page = 100;
  while(page &lt;= last_page) {
    request("http://some_json_server.com/data?page=" + page, function (error, response, body) {
      if (!error &amp;&amp; response.statusCode == 200) {
        store_data(body)
      }
      page++;
    });                
  }
  </code></pre>
  
  <p>I've done the following, but it is actually not retrieving anything. Am I doing this correctly?</p>
  
  <pre><code>var page = 2;
  var last_page = 100;
  while(page &lt;= last_page) {
  var async_arr = [];
  async_arr.push(
    function(next) {
      request("http://some_api_url?page=" + page, function (error, response, body) {
        if (!error &amp;&amp; response.statusCode == 200) {
          store_data(body);
        }
      });
    }
  );
  
  async.series(
    async_arr, done
  );
  </code></pre>