Tengo un método que realiza 2 llamadas API simultáneamente. ¿Cómo puedo tomar los resultados de las llamadas a la API y manipularlos con otro método dentro del mismo componente de Vue?
buildChart(){ *method where calls would be manipulated" } async updateChart() { this.isLoading = true; const apiCall1 = await get().then((result) => { console.log(result); this.isLoading = false; }); const apiCall2= await get().then((result) => { console.log(result); this.isLoading = false; }); }Puede usar Promise.all para ejecutar las dos solicitudes en paralelo, el resultado será una matriz de dos elementos de cada solicitud asíncrona.
async buildChart(){ // here result will be an array with two items of the result of each async get method. const [firstRequest, secondRequest] = await updateChart() this.isLoading = false; }, updateChart() { this.isLoading = true; return Promise.all([get(), get()]) }