Created
November 2, 2020 09:57
-
-
Save myesn/a637fc62b49ede1bd7af82801e7a03fe to your computer and use it in GitHub Desktop.
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
const p = new Promise((resolve, reject) => { | |
const a = 1 + 1; | |
if (a === 2) { | |
resolve('Success'); | |
} else { | |
reject('Faild'); | |
} | |
}); | |
p.then((message) => { | |
console.log(message); | |
}).catch((error) => { | |
console.log(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment