Skip to content

Instantly share code, notes, and snippets.

@TorbenKoehn
Created September 14, 2016 11:49
Show Gist options
  • Save TorbenKoehn/fd2a045dc6f2918b71ff16634eed7771 to your computer and use it in GitHub Desktop.
Save TorbenKoehn/fd2a045dc6f2918b71ff16634eed7771 to your computer and use it in GitHub Desktop.
function getAllProducts()
{
var p = new Promise(),
page = 1,
results = [];
function requestPage()
{
doRequestInSomeWay(page).then(function(result) {
if (result.success === false) {
p.resolve(results);
return;
}
result.entries.forEach(function(resultEntry) {
results.push(resultEntry);
});
page++;
requestPage();
});
}
return p;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment