A Pen by pranishabudhathoki on CodePen.
Created
October 25, 2021 13:09
-
-
Save pranishabudhathoki/c3293bbd31fd3585d6f166b2af6ae6f2 to your computer and use it in GitHub Desktop.
promise example
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
let p = new Promise((resolve,reject)=> { | |
let a = 1+2; | |
if( a == 2){ | |
resolve("success") | |
} else{ | |
reject('failed') | |
} | |
}) | |
p.then((message)=>{ | |
console.log('this is in the then' + message) | |
}).catch((message)=>{ | |
console.log('this is in catch' + message) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment