Skip to content

Instantly share code, notes, and snippets.

@vish448
Created May 11, 2019 17:49
Show Gist options
  • Save vish448/13d091b8d894dcbf46a485325fdc6b3a to your computer and use it in GitHub Desktop.
Save vish448/13d091b8d894dcbf46a485325fdc6b3a to your computer and use it in GitHub Desktop.
Creating a promise
function onSuccess(){
console.log('Success ✌️')
}
function onError(){
console.log('Error 💩')
}
var promise = new Promise((resolve, reject)=>{
resolve(); // will execute the On success method
reject(); // will execute the On Error method
}, 400)
promise.then(onSuccess)
promise.catch(onError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment