Created
October 22, 2020 17:29
-
-
Save arihantdaga/a02621342a86e40d69215977e4c537b8 to your computer and use it in GitHub Desktop.
Return or Not Return after resolving/rejecting a promise
This file contains 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)=>{ | |
setTimeout(()=>{ | |
resolve("Hello"); | |
console.log("Will I be printed"); | |
}, 2000); | |
}); | |
p.then(data=>{ | |
console.log(data); | |
}).catch(err=>{ | |
console.log(err); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment