AngularJs. $http post not posting all the items to a collection in a for loop

I have a collection to which I need to post several items in a for loop. Here is code for that:

for(i = 0; i < 28; i++) { var request = $http({ method: "post", url: "/students", data: { studentName: "Student", answerImage: "image", questionPrompt: 1 } }).then(function successCallback(response) { }, function errorCallback(response) { console.log(response); }); }

When I search the collection, it only posted 23 items. I have cleared my collection and tried this several times and each time it posts only 20-23 items. All the fields for the data are fine. This is the error response I get on the console:

Object {data: null, status: -1, config: Object, statusText: ""}

I am not sure what to do from here. In my real app, I would need to post something like ~200 items to this collection in this for loop. Is it a timing out issue?



It's possible you might be running into a timeout here because the browser is going to rate limit how many concurrent requests you can make to the same domain. <strong>Typically that number is 6, but differs depending on the browser.</strong>

In general, making 200+ HTTP requests at once is going to be a real drag on your application.

A better approach would be to either modify your endpoint to take a collection, or create a new endpoint that does. A single request with 200 objects is going to be much more performant than trying to make 200 individual requests.


  • how to use/store JSON data after the callback has fired?
  • how to increase size of post parameter list
  • Setting null for single-valued navigation property using Xrm.WebApi
  • Attemping to change attributes of $(this) inside success function
  • MarkLogic Node.js Sort on “last-modified”
  • How to wait for all async tasks to finish in Node.js?
  • call a java program from a webapp in tomcat server - the java program is out side of tomcat server
  • PWA with multiple pages
  • Should I be afraid to use UDP to make a client/server broadcast talk?
  • Ionic storage “get” returns null only on the second call within method
  • Google OAuth: can't get refresh token with authorization code
  • What command do i need to pass in SabreCommandLLSRQ to get current price of PNR?
  • Can't delete or rename original file after resizing
  • Execute scripts AJAX returns
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Google Custom Search with transparent background
  • Seeking advice on Jetty HttpClient Hang
  • Using variable in a value field in jMeter
  • Why is an OPTIONS request sent to the server?
  • Insert into database using onclick function
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • What is Eclipse's Declaration View used for?
  • DotNetZip - Calculate final zip size before calling Save(stream)
  • Is there a amazon webstore API for customers?
  • How to get a value (ex: baseURL) in every Karate feature?
  • How to add date and time under each post in guestbook in google app engine
  • Perl system calls when running as another user using sudo
  • Can I make an Android app that runs a web view in Chrome 39?
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Upload files with Ajax and Jquery
  • How to pass list parameters for each object using Spring MVC?
  • Is there a mandatory requirement to switch app.yaml?
  • File upload with ng-file-upload throwing error
  • ExecuteAsync RestSharp to allow backgroundWorker CancellationPending c#
  • AngularJs get employee from factory
  • Proper way to use connect-multiparty with express.js?
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?