Dynamically synchronous request axios How do I make an axios synchronous request dynamically?
var array = [0,1,2];
axios.get('api/' + array[0]).then(response => {
axios.get('api/' + array[1]).then(response => {
axios.get('api/' + array[2]).then(response => {
alert('done');
});
});
});
You can do something like this
axios.all([
axios.get('http://google.com'),
axios.get('http://apple.com')
]).then(axios.spread((googleRes, appleRes) => {
// do something with both responses
});
So your homework is to make this dynamically ;)
Documentation: https://github.com/axios/axios#example
Please sign in or create an account to participate in this conversation.