Created
May 11, 2019 17:49
-
-
Save vish448/13d091b8d894dcbf46a485325fdc6b3a to your computer and use it in GitHub Desktop.
Creating a promise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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