Created
October 18, 2018 05:22
-
-
Save salmanx/baa7a1041fba7c38483bbd8878cad8a9 to your computer and use it in GitHub Desktop.
an example how promise work in javascript
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
const p = new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(1); | |
// reject(new Error('message')); | |
}, 2000) | |
}); | |
p.then(result => console.log("Result", result)).catch(err => console.log("Error", err.message)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment