JSFiddle - React, Tailwind, and code Playground
JavaScript
var promiseA = new Promise(function(resolve, reject) {
setTimeout(function() {
resolve('woop woop');
}, 500);
});
var promiseB = new Promise(function(resolve, reject) {
setTimeout(function() {
reject('suckah');
}, 1000);
});
promiseA.then(function() {
return promiseB;
});
promiseA.then(function(msg) {
alert('promiseA.then: ' + msg);
});
/* Rentrera pas dans le catch de la promesse A. */
promiseA.catch(function(msg) {
alert('promiseA.catch: ' + msg);
});
/* Rentrera pas dans le then de la promesse B. */
promiseB.then(function(msg) {
alert('promiseB.then: ' + msg);
});
promiseB.catch(function(err) {
alert('promiseB.catch: ' + err);
});