Is there any other way other than `setTimeout()` to wait for the result come back after api call and then call that api again immediately after result is received?

In my case, I have to call `n` times times (depending on user input) and the api call takes 20-40 seconds to process and return result from the backend. If I send another request, while the previous one is still being processed in the backed, then it breaks the backend.

What is the right way to do call api once result is received and fully processed?

```
sendRequest() {
    let self = this;
        function f() {
            if (self.state.callPerSite < self.state.selectedSites.length) {
                self.processData(transid);
                   setTimeout(f, 20)
                }
            } else {
                self.setState({progress: 100});
            }
        }
        f();
} 

processData(transid) {
        rest.apiCall({transactionId: transid}, 'json').then(results => {

            if (!firstCallIsProcessed) {
                firstCallIsProcessed = true;
            }
            callPerSite++;

            this.setState({
                resultsData: results.data,
                callPerSite: callPerSite
            });

        }).catch(err => this.onError(err));

```