title: How to execute the code 1st and then introduce delay
body: <p>Is there a better way to execute code 1st and then introduced the delay. Right now code is working perfectly. But I want to know is there any better way to write code means without using delayFlag.</p>
  
  <p>Details:</p>
  
  <p>requestConfigs: contains n number of the object which contain details needed to make a fetch request</p>
  
  <p>delayFlag: it will activate after 1st for loop is on the last round</p>
  
  <p>this.getMyData(details): is a function which is fetching data from the endpoint </p>
  
  <p>this.getFetchDetails(): This funtion contains this for loop I try to make the recurtion.</p>
  
  <pre><code>for(let i=0 ; i &lt; requestConfigs.length ; i++){
  
        if(this.state.delayFlag === true){ // NOTE: This approch is the Issue
          await this.delay(5000)
        }
  
        console.log("5 SEC")
        await this.getMyData(requestConfigs[i])
        await this.setState({ dashboard: dashboardResponse.data, initialDataFeatchFlage: false });
  
        if(i === requestConfigs.length-1){
          await this.setState({ delayFlag: true });
          this.getFetchDetails();
        }
      }
  </code></pre>