title: Waiting for all promises called in a loop to finish
body: <p>I'm using <a href="https://github.com/mzabriskie/axios" rel="noreferrer">the axios</a> promise library, but my question applies more generally I think.  Right now I'm looping over some data and making a single REST call per iteration.<br>
  As each call completes I need to add the return value to an object.  At a high level, it looks like this:</p>
  
  <pre><code>var mainObject = {};
  
  myArrayOfData.forEach(function(singleElement){
    myUrl = singleElement.webAddress;
    axios.get(myUrl)
    .then(function(response) {
      mainObject[response.identifier] = response.value;
     });
  });
  
  console.log(convertToStringValue(mainObject));
  </code></pre>
  
  <p>What's happening of course is when I call <code>console.log</code> the <code>mainObject</code> doesn't have any data in it yet, since axios is still reaching out.  What's a good way of dealing with this situation?  </p>
  
  <p>Axios does have an <code>all</code> method along with a sister <code>spread</code> one, but they appear to be of use if you know ahead of time how many calls you'll be making, whereas in my case I don't know how many loop iterations there will be.</p>