Skip to content

Instantly share code, notes, and snippets.

@wvxavier

wvxavier/promise-example.js Secret

Created Aug 24, 2020
Embed
What would you like to do?
promise-example
const doWorkPromise = new Promise((resolve, reject) =>{
setTimeout(() => {
resolve([1,2,3])
// reject('This is an error!')
}, 2000)
})
doWorkPromise.then((result) => {
console.log('Success!', result)
}).catch((error) => {
console.log(error)
})
// Fulfilled
// /
// Promisse --> Pending -- >
// \
// Rejected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment