title: React Axios API call with array loop giving wrong order?
body: <p>I was learning react and doing some axios api call with an array. I did a code on gathering data through coinmarketcap api to learn.</p>
  
  <p>So, my intention was to get the prices from the api with a hardcoded array of cryptocurrency ids and push them into an array of prices. But I ran into a problem with the prices array, as the prices were all jumbled up. I was supposed to get an array in this order</p>
  
  <p>[bitcoinprice, ethereumprice, stellarprice, rippleprice]</p>
  
  <p>but when I ran it in the browser, the prices came randomly and not in this order, sometimes I got my order, sometimes it didn't. I used a button which onClick called the getPrice method. Does anyone know what went wrong with my code? Thanks!</p>
  
  <pre><code>constructor(){
      super();
  
      this.state = {
          cryptos:["bitcoin","ethereum","stellar","ripple"],
          prices:[]
      };
  
      this.getPrice = this.getPrice.bind(this);
  
  }
  
  
  getPrice(){
      const cryptos = this.state.cryptos;
      console.log(cryptos);
  
      for (var i = 0; i &lt; cryptos.length; i++){       
          const cryptoUrl = 'https://api.coinmarketcap.com/v1/ticker/' + cryptos[i];
  
      axios.get(cryptoUrl)
          .then((response) =&gt; {
              const data = response.data[0];
              console.log(data.price_usd);
  
              this.state.prices.push(data.price_usd);
              console.log(this.state.prices);
          })
  
          .catch((error) =&gt; {
          console.log(error);
          }); 
      }
  
  }
  </code></pre>