Then do that instead of writing to the DOM (like my example does)
Just wanted to illistrate an example of how I paginate.
So you probably want something like
Pseudo javascript
let streams = [];
function getStreams(cursor) {
let url = new URL('https://api.twitch.tv/helix/streams');
let params = [
[ 'first', '100' ],
[ 'game_id', '509658' ]
];
if (cursor) {
params.push([ 'after', cursor ]);
}
url.search = new URLSearchParams(params).toString();
// make request to twitch using `url`
// Parse response
// store streams in the array
streams = streams.concat(resp.data);
// another page?
if (resp.hasOwnProperty('pagination') && resp.pagination.hasOwnProperty('cursor')) {
getStreams(resp.pagination.cursor);
} else {
// all done
processStreams();
}
}
function processStreams() {
// do something with `streams`
}