title: Asynchronous / Synchronous Looping Node.js
body: <p>Hi I'm trying to do something a little weird here it's kind of mixing async and sync together hence why it's not working how I expected. Currently runs for 3 users from the array then ends how would I get this to run for the entire length of the usernames in the array?</p>
  
  <pre><code>var i = 0,
  fs = require('fs'),
  fetch = require('node-fetch');
  
  fs.readFile('file.txt', function(err, data) {
    var array = data.toString().split("\n");
    getCreationDate(array);
  });
  
  function getCreationDate(array) {
    fetch('http://mytwitterbirthday.com/api/?screen_name=' + array[i])
    .then(function(res) {
      return res.json();
    }).then(function(json) {
      console.log(i, array[i])
      console.log(json[0].screen_name, json[0].created_at);
    }).then(function() {
      i++;
      getCreationDate(array);
    })
  }
  </code></pre>