January 2018
Intermediate to advanced
332 pages
7h 36m
English
Pyramid of doom is a classic scenario where we have tons of nesting or branching. This makes the code overly complex and the unit testing a very complex job:
promise1() .then((resp) => { promise2(resp) .then((resp2) => { promise3(resp2) .then((resp3) => { if(resp3.something) { // do something } else { // do something else } }); }); });
Instead, do the following:
promise1() .then((resp) => { return promise2(resp); }) .then((resp2) => { return promise3(resp2); }) .then((resp3) => { if(resp3.something) { // do something } else { // do something else } })
Read now
Unlock full access