title: Using async await when mapping over an arrays values
body: <p>I am trying to use the new async/await in conjunction with mapping over an array of values.
  However I am a bit confused, which should have the await keyword infront of it, in this specific scenario.</p>
  
  <p>There isnt much information regarding this topic yet.</p>
  
  <p>I am trying to simply <code>map()</code> over and array of values, which are used in an Axios <code>get()</code> request, which then returns a <code>then()</code> value, which gets added to the array returned by the <code>map()</code> function.</p>
  
  <p>This is my code right now:</p>
  
  <pre><code>async function get_prices (arrayOfDates, crypto, FIAT) {
    // I tried this way (return value can be found below)
    let arry_of_prices = arrayOfDates.map(async function(date){
      let a = await fetch_data(date, crypto, FIAT)
      return a
    });
  
    // And this way (return value can be found below)
    let arry_of_prices = await arrayOfDates.map(date =&gt; fetch_data(date, crypto, FIAT));
  } 
  
  const fetch_data = (timestamp, crypto, FIAT) =&gt; {
    axios.get(`https://min-api.cryptocompare.com/data/pricehistorical?fsym=${crypto}&amp;tsyms=${FIAT}&amp;ts=${timestamp}`)
    .then(function (response) {
      return Object.values(response.data).map(key =&gt; Object.values(key))[0][0]
    })
    .catch(function (error) {
      console.log(error);
    });
  }
  
  let arr = [1468965600, 1469052000, 1469138400,1469484000]
  
  get_prices(arr, "BTC", "USD").then(arr =&gt; console.log(arr))
  </code></pre>
  
  <p>The first try returned 4 <code>resolved</code> promises, but the values were <code>undefined</code>.
  Whereas the second return an array with 4 <code>undefined</code>.</p>
  
  <p>Does anyone have an idea of how this could be structured, so that the <code>map()</code> waits until the function is resolved and then adds the value to the array?</p>