Using Node 4.x. When you have a Promise.all(promises).then()
what is the proper way to resolve the data and pass it to the next .then()
?
I
Your return data
approach is correct, that's an example of promise chaining. If you return a promise from your .then()
callback, JavaScript will resolve that promise and pass the data to the next then()
callback.
Just be careful and make sure you handle errors with .catch()
. Promise.all() rejects as soon as one of the promises in the array rejects.