How should I stop the promise chain in this case? Execute the code of second then only when the condition in the first then is true.
var p = new Promise((res
You could move the chain into the conditional branch:
p.then((res) => { if(true) { return Promise.resolve(res + 2).then((res) => { // executed only when the condition is true }); } else { // do something // chain ends here } });