Answer the question
In order to leave comments, you need to log in
How to make multiple requests at the same time in Vue+Axios?
Hello!
Tell me, is it possible to make several requests in parallel in one Vue component?
I assume that it is possible, but how good is this approach or is it still better to make each request in a separate component?
The code from this example did not help.
Thank you for your help!
Answer the question
In order to leave comments, you need to log in
Promise.all([
axios.get('/user/12345'),
axios.get('/user/12345/permissions')
]).then(([
user,
permissions
]) => {
console.log(user, permissions);
///
});
Multiple simultaneous requests can be made using axios.all
function getUserAccount() {
return axios.get('/user/12345');
}
function getUserPermissions() {
return axios.get('/user/12345/permissions');
}
axios.all([getUserAccount(), getUserPermissions()])
.then(axios.spread(function (acct, perms) {
// Both requests are now complete
}));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question