JSFiddle - React, Tailwind, and code Playground
by Yuriy Petrichenko
JavaScript
const promise = new Promise(function(resolve) {
setTimeout(() => {
resolve(5);
}, 1000);
});
promise
.then(result => {
console.log(result, 'RESULT');
let nextValue = result + 2;
throw Error('Hello boom!');
return nextValue;
})
.catch(error => {
console.log('SOME ERROR HAS BEEN OCCURED!', error);
})
.then(result1 => {
console.log(result1, 'RESULT 1');
let nextValue = result1 + 2;
return nextValue;
})
.then(result2 => {
console.log(result2, 'RESULT 2');
let nextValue = result2 + 2;
return nextValue;
})
/* .catch(error => {
console.log('SOME ERROR HAS BEEN OCCURED!', error);
})
*/