title: Create array of promises
body: <p>I have an array of coins, which I get from a database query. I pass this array to a function that needs to do an API call for each coin to get the value. </p>
  
  <p>The FOR loop like this below will result in: 
  (</p>
  
  <p>)</p>
  
  <pre><code>// for (let i =0; i &lt;= coins.length-1; i++){
  //             console.log(i);
  //              await (this.coinRepository.getActiveCoinAsync(i.coinName)
  //                 .then(response =&gt; {
  //                     // console.log((response[0].price_eur))
  //                     // console.log((result[i].amount))
  //                     // console.log( value +(response[0].price_eur) * (result[i].amount))
  //
  //                     value = value +((response[0].price_eur) * (i.amount))
  //                     console.log(value)
  //
  //                 })
  //                 .catch(error =&gt; reject(error))
  //             )
  //         }
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>console.log(i)
  console.log(i)
  console.log(i)
  value
  value
  value
  </code></pre>
  
  <p>I tried this below but it doesn't seem to execute any promises:</p>
  
  <pre><code>return new Promise((resolve, reject) =&gt; {
  let value = 0;
  let promises =[];
  for (let i =0; i &lt;= coins.length-1; i++){
      let promise =  (this.coinRepository.getActiveCoin(coins[i].coinName))
      promises.push(promise);
      console.log(promise);
  }
  console.log(promises);
  Promise.all(promises)
     .then(results =&gt;{
          console.log(results);
      })
     .catch(error =&gt; reject(error))
  </code></pre>
  
  <p>coinRepository.getActiveCoin</p>
  
  <pre><code>    getActiveCoin(coin) {
      return new Promise((resolve, reject) =&gt; {
          console.log(coin)
          request('https://api.coinmarketcap.com/v1/ticker/'+coin+'/?convert=EUR', function (error, response, body) {
              if (!error &amp;&amp; response.statusCode == 200) {
                  resolve (JSON.parse(body));
              }else {
                  reject(error);
              }
          })
  
      });
  }
  </code></pre>