Created
January 29, 2018 16:26
-
-
Save markbiek/467a21283a17f63b98ed48d80c4331b6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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* 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