Answer the question
In order to leave comments, you need to log in
Loops in nodejs, how to implement correctly?
How to properly implement cycles in nodejs, when is it better to use promise, callback, closures, and async?
And is this form of executing sequential functions through promises correct?
Example
getData1(data)
.then(getData2(data)
.then(getData3(data)
.then(...)
)
)
Answer the question
In order to leave comments, you need to log in
The question is not entirely clear.
If you are making an asynchronous call, you are using a promise. If not, don't use it.
Your example with sequential operations is also incorrectly written. It would be more correct like this:
getData1()
.then(data => {
return getData2(data);
})
.then(data => {
return getData3(data)
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question