How to Use axios.all() to Make Concurrent HTTP Requests

Jan 20, 2021

axios.all() is Axios's own way of making concurrent HTTP requests and getting back an equal number of responses that you can have either in an array using destructuring or a separate variable for each one. We recommend assigning the return value of axios.get() to a variable before passing it into axios.all() to make your code more readable as axios.all() takes a spread of requests. Here's how you can use axios.all() to make 3 requests in parallel:

const axiosrequest1 = axios.get('');
const axiosrequest2 = axios.get('');
const axiosrequest3 = axios.get('');
// you could also use destructuring to have an array of responses
await axios.all([axiosrequest1, axiosrequest2, axiosrequest3]).then(axios.spread(function(res1, res2, res3) {

More Axios Tutorials