Skip to content

Instantly share code, notes, and snippets.

@hachi8833
Created March 12, 2021 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hachi8833/13565a94704f2fe7afd2e4e5235249f4 to your computer and use it in GitHub Desktop.
Save hachi8833/13565a94704f2fe7afd2e4e5235249f4 to your computer and use it in GitHub Desktop.
Promise sample code 3
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