DEV Community

Discussion on: Then After forEach

Collapse
 
forstermatth profile image
Matt Forster • Edited

Yes, This is definitely the solution! Node has native support for dealing with multiple async promises.

You could even remove the variable assignment (though JS is going to assign it to a temp anyways);


return Promise.all(orders.map(api.sendOrder))
  .then(allOrders => {
    ...
  });

Thats if sendOrder does not need its functional context. Semantically the same solution, though.