Created
March 12, 2021 08:56
-
-
Save hachi8833/13565a94704f2fe7afd2e4e5235249f4 to your computer and use it in GitHub Desktop.
Promise sample code 3
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
new Promise(function(resolve, reject) { | |
setTimeout(() => resolve(1), 2000); | |
}).then((result) => { | |
alert(result); | |
return result + 2; | |
}).then((result) => { | |
throw new Error('FAILED HERE'); | |
alert(result); | |
return result + 2; | |
}).then((result) => { | |
alert(result); | |
return result + 2; | |
}).catch((e) => { | |
console.log('error: ', e) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment