-
-
Save TorbenKoehn/fd2a045dc6f2918b71ff16634eed7771 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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