Skip to content

Instantly share code, notes, and snippets.

@wvxavier
Created August 24, 2020 08:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wvxavier/f1d80d9f5c283f4701e34cec653cc3a1 to your computer and use it in GitHub Desktop.
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