Answer the question
In order to leave comments, you need to log in
How to correctly format multiple requests in axios?
There is an array c url
let url = ["https://www.google.ru", "https://toster.ru"]
axios.get(url).then(function (response) {
console.log(response);
})
for (let i = 0; i < url.length; i++) {
axios.get(url[i]).then(function (response) {
console.log(response);
})
}
Answer the question
In order to leave comments, you need to log in
const urls = ["https://www.google.ru", "https://toster.ru"];
Promise.all(urls.map(url => axios.get(url)))
.then(responses => console.log('Complete', responses));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question