Reputation: 13125
Consider this code where start
, continue
and finish
are promises.
export const do = () => {
return new Promise((resolve, reject) => {
start()
.then(() => continue())
.then(() => finish())
.then(() => resolve())
.catch((reason) => reject(reason))
});
};
Is this how to write nested promises?
Upvotes: 1
Views: 91
Reputation: 214949
Just return the whole chain, no need to wrap it:
export const _do = () => start()
.then(continue)
.then(finish)
;
Upvotes: 1