Skip to content

Instantly share code, notes, and snippets.

@khaosdoctor
Created April 7, 2019 18:26
Show Gist options
  • Save khaosdoctor/010ad81f716128e673c31dc0fbf9806d to your computer and use it in GitHub Desktop.
Save khaosdoctor/010ad81f716128e673c31dc0fbf9806d to your computer and use it in GitHub Desktop.
var p = Promise.resolve()
.then(data => new Promise(function (resolve, reject) {
setTimeout(Math.random() > 0.5 ? resolve : reject, 1000)
}))
p.then(data => console.log('yay'))
p.catch(data => console.log('ops'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment