I'd like to do something like this:
return1stPromise()
.then(if1stPromiseSucceeds) // returns 2nd Promise
.catch(if1stPromiseFails)
.then(if2ndPromiseSucceeds) // execute only if 1st Promise succeeds
I'd like the 2nd .then
to execute only if 1st Promise succeeds. Or in different words - I don't want the 2nd .then
to execute if the catch has been executed.
Is this even possible or do I have nest the 2nd promise inside the first then
like this:
return1stPromise()
.then(function (data) {
return if1stPromiseSucceeds(data).then(if2ndPromiseSucceeds);
})
.catch(if1stPromiseFails);
In addition - any good resources on how to control flow with Promises where it's more thread like?