I currently have an async function that is similar to below. It returns an object which contains the results of several api calls(using axios - so each call returns a promise).
the problem i have is that the 3 api calls could be called at same time, but currently i am awaiting each one.
How would i be able to fire them all off at same time but still make sure the function only returns when all have finished. Do i need to put in a promise.all?
export async function GetItems(){
let items ={
items1:[],
items2:[],
items3:[]
}
await service.getItems1().then(r=>{
items.items1 = r.data
}
await service.getItems2().then(r=>{
items.items2 = r.data
}
await service.getItems3().then(r=>{
items.items3 = r.data
}
return items;
}