Skip to content

Instantly share code, notes, and snippets.

@Abazhenov
Last active June 21, 2018 11:03
Show Gist options
  • Save Abazhenov/d4fb1f6907650828233732414b6d342b to your computer and use it in GitHub Desktop.
Save Abazhenov/d4fb1f6907650828233732414b6d342b to your computer and use it in GitHub Desktop.
const getInfo = () =>
axios.get('/users')
.then(users => {
console.log(users)
})
.then(() => getGroups())
.then(groups => {
console.log(groups)
})
.then(() => getFavorites())
.then(favorites => {
console.log(favorites)
return 'all done'
}
getInfo()
@iamjochem
Copy link

the above can be written more consisely (making the code alot less egregious when compared to the async/wait version)

const getInfo = () => 
  axios.get('/users')
    .then(console.log)    
    .then(getGroups)
    .then(console.log)
    .then(getFavorites)
    .then(console.log)
    .then(() => 'all done')

getInfo()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment