Is there ever a case where both then() and catch() will fire?
read(start).then(() => {
console.log('DONE:', h.addCommas(data));
}).catch((err)=>{
console.log('ERROR:');
console.log(err);
})
Is there ever a case where both then() and catch() will fire?
read(start).then(() => {
console.log('DONE:', h.addCommas(data));
}).catch((err)=>{
console.log('ERROR:');
console.log(err);
})
Yes, both can fire.
Case 1: doSomething().then(successHandler).catch(errorHandler) - if doSomething is successful and successHandler throws, then errorHandler will fire (otherwise it won't).
Case 2: doSomething().catch(errorHandler).then(successHandler) - if doSomething throws and errorHandler doesn't throw, then successHandler will fire (otherwise it won't).