Skip to content

Instantly share code, notes, and snippets.

@hachi8833
Created Mar 12, 2021
Embed
What would you like to do?
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