Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function methodThatCleansUpStuff(){
// dont return anything cause you are just cleaning up
}
function doAsyncStuff() {
return methodThatGivesAPromise()
.then(otherMethodThatGivesAPromise)
.then(()=>{throw new Error(“BOOM”)})
.then(otherOtherMethodThatGivesAPromise)
.catch(methodThatCleansUpStuff)
}
doAsyncStuff().then(()=>{
console.log('promise was resolved!!')
})
.fail(()=>{
console.log('promise was rejected!!')
})
// this prints 'promise was resolved!!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.