Answer the question
In order to leave comments, you need to log in
How to organize the structure of promises in asynchronous code?
I have a set of asynchronous functions that need to be executed one after the other. If one returns catch, the whole chain is interrupted. This is easy to do using a promise chain
.then().then().then().catch()
But for me it is important that each function has its own catch and leaves the chain execution in case of an error
The only option that comes to mind
is func.then( () => {
func2.then(() => {
func3.then
(....).catch ()}).catch ()}).catch()
he is the embodiment of callback hell, which promises must solve
Answer the question
In order to leave comments, you need to log in
asynchronous functions.
Instead of
something().then(() => {
something2().then(() => {
})
})
await something();
await something2();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question