Skip to content

Instantly share code, notes, and snippets.

@ryanwischkaemper
Created September 30, 2015 17:01
Show Gist options
  • Save ryanwischkaemper/4ded1ddab26f15d616e5 to your computer and use it in GitHub Desktop.
Save ryanwischkaemper/4ded1ddab26f15d616e5 to your computer and use it in GitHub Desktop.
Javascript synchronous promise execution
var promises = [];
for(var i = 0; i < 10; i++)promises.push({config: i});
// execute each request synchronously
return promises.reduce(function (promise, item) {
return promise.then(function () {
return myService.thatReturnsPromise(item);
});
}, $q.when());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment