title: Best way to call an asynchronous function within map?
body: <p>I'm mapping over an array and for one of the return values of the new object, I need to make an asynchronous call.</p>
  <pre><code>var firebaseData = teachers.map(function(teacher) {
    return {
      name: teacher.title,
      description: teacher.body_html,
      image: urlToBase64(teacher.summary_html.match(/src=&quot;(.*?)&quot;/)[1]),
      city: metafieldTeacherData[teacher.id].city,
      country: metafieldTeacherData[teacher.id].country,
      state: metafieldTeacherData[teacher.id].state,
      studioName: metafieldTeacherData[teacher.id].studioName,
      studioURL: metafieldTeacherData[teacher.id].studioURL
    }
  });
  </code></pre>
  <p>The implementation of that function will look something like</p>
  <pre><code>function urlToBase64(url) {
    request.get(url, function (error, response, body) {
      if (!error &amp;&amp; response.statusCode == 200) {
        return &quot;data:&quot; + response.headers[&quot;content-type&quot;] + &quot;;base64,&quot; + new Buffer(body).toString('base64');
      }
    });
  }
  </code></pre>
  <p>I'm not clear what's the best approach to do this... promises? Nested callbacks? Use something in ES6 or ES7 and then transpile with Babel?</p>
  <p>What's the current best way to implement this?</p>