Skip to content

Instantly share code, notes, and snippets.

@neufeldtech
Created October 15, 2015 16:22
Show Gist options
  • Save neufeldtech/0187c251b28f98f98c25 to your computer and use it in GitHub Desktop.
Save neufeldtech/0187c251b28f98f98c25 to your computer and use it in GitHub Desktop.
Looping through http calls in angular controller
for (var i = 1; i < 6; i++) { // 6 is just a given number, it could be 1 or 100....
(function(i){
http({method: 'POST', url: '/path/to/rest/friend', data: {"name":"Auto Friend " + i}})
.then(function (response) {
console.log("friend created");
console.log(response);
}, function () {
console.log('Whoops...');
});
})(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment