[Vuejs]-Adding multiple fetch request inside a method using vuejs

0👍

Async & Await will made the trick

async submit() {
   const request1 = '...';
   const request2 = '...';
   const response1 = await fetch(request1).then(response => response.data)
   const response2 = await fetch(request2).then(response => response.data)
}

However, it’s highly recommended to request all together for optimize by using

Promise.all([...])

Remember to set catch as well in each fetch, for managing possible endpoint errors

Leave a comment