Skip to content

Instantly share code, notes, and snippets.

@markbiek
Created January 29, 2018 16:26
Show Gist options
  • Save markbiek/467a21283a17f63b98ed48d80c4331b6 to your computer and use it in GitHub Desktop.
Save markbiek/467a21283a17f63b98ed48d80c4331b6 to your computer and use it in GitHub Desktop.
function* getLogs(url) {
// Loop forever, yielding the results of the ajax call to the caller
while (true) {
yield axios.get(url, {}).then(resp => {
const { data: { paging, items } } = resp;
if (items && items.length > 0) {
// If we have more items to retrieve, change the url to the next url for the successive call
url = paging.next;
// Return the response data
return resp.data
} else {
return null;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment