Skip to content Skip to sidebar Skip to footer

Maintaining Order Of Http Requests Within A For Loop In Javascript

I am trying to save an array of objects in MongoDB using node.js express and mongoose (MEAN stack). However, when I make the http post requests on the front end for each item in th

Solution 1:

It's wasteful sending $scope.array.length number of HTTP requests when you have all the data you want to send ready.

Just post the whole array to your backend and then you can save them in a loop on the backend using something like async to guarantee the order.

Post a Comment for "Maintaining Order Of Http Requests Within A For Loop In Javascript"