Skip to content

Instantly share code, notes, and snippets.

@coffeepostal
Created March 9, 2020 19:28
Show Gist options
  • Save coffeepostal/f0dd480feb1062c6569a305700ca73e4 to your computer and use it in GitHub Desktop.
Save coffeepostal/f0dd480feb1062c6569a305700ca73e4 to your computer and use it in GitHub Desktop.
AxiosJS: Send Multiple Requests
import axios from 'axios';
let one = "https://api.storyblok.com/v1/cdn/stories/health?version=published&token=wANpEQEsMYGOwLxwXQ76Ggtt"
let two = "https://api.storyblok.com/v1/cdn/datasources/?token=wANpEQEsMYGOwLxwXQ76Ggtt"
let three = "https://api.storyblok.com/v1/cdn/stories/vue?version=published&token=wANpEQEsMYGOwLxwXQ76Ggtt"
axios.all([requestOne, requestTwo, requestThree]).then(axios.spread((...responses) => {
const responseOne = responses[0]
const responseTwo = responses[1]
const responesThree = responses[2]
// use/access the results
})).catch(errors => {
// react on errors.
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment