title: How to handle asynchronous tasks in axios
body: <p>The arr variable below is a collection of similar arrays.</p>
  
  <pre><code> function site1(url){
      return axios.get(url)
       .then((response)=&gt;{
          if(response.status==200){
              //code for getting data
              //arr=[]---------initial value  (globally declared variable)
              for(i=1;i&lt;=limit;i++){
                  arr.push(someData);
                  //after this push arr=[[item1,item2,item3,item4,item5]]
                  //arr is an collection of similar arrays
                  //there are many links one for each array inside arr
                  //-----operation here to get someLink-------
  
  
                  for(a=0;a&lt;arr.length;a++){
                      someOtherSite(somelink,arr).then((data)=&gt;{
                          arr=data;
  
                      });
                  }
              }
  
  
          }
  
          return arr;
  
      })
  
    }
  
  function someOtherSite(url,arr){
   return axios.get(url)
            .then(response=&gt;{
           //get some dataItem
            arr[arr.length-1].push(dataItem);
            return arr;
     })
   }
  </code></pre>
  
  <p>for function call :</p>
  
  <pre><code>site1(url).then(data=&gt;{
       console.log(data);
     })
  </code></pre>
  
  <p>I wanted the value of arr to be like this:
  arr=[[item1,item2,item3,item4,item5,dataItem],.......]
  but the return happens before and the value of arr is displayed without the dataItem.
  How to i make the returning of the value wait and occur after the process has been completed.</p>