Skip to content

Instantly share code, notes, and snippets.

@dmamills
Forked from Gaafar/if-promise.js
Created March 27, 2017 18:24
Show Gist options
  • Save dmamills/96e16b23e8cc327139b5716e16f444b6 to your computer and use it in GitHub Desktop.
Save dmamills/96e16b23e8cc327139b5716e16f444b6 to your computer and use it in GitHub Desktop.
const makeRequest = () => {
return getJSON()
.then(data => {
if (data.needsAnotherRequest) {
return makeAnotherRequest(data)
.then(moreData => {
console.log(moreData)
return moreData
})
} else {
console.log(data)
return data
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment