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
- [Vuejs]-Vuejs Unexpected token < in JSON at position 0 from express server
- [Vuejs]-Handle multiple inputs in Vue 3
Source:stackexchange.com