I am facing a challenge where I have an array of data that needs to be fetched using a for loop. However, I want to fetch this data asynchronously to make multiple calls at the same time. Additionally, once all the data has been fetched, I need to perform some data manipulation which should be done after all the data has been retrieved.
for (var e in this.dataTofetch) {
axios
.get("https://www.example.com/api/" + e)
.then((response) => this.fetchedData.push(response.data));
}
this.manipulateData();
The issue lies in the fact that when I try to run the manipulateData function, the fetchedData is empty.
I also experimented with trying to execute the code synchronously using await, but this resulted in slow performance when making multiple calls.