// store streams in the array
streams = streams.concat(resp.data);
Will put all the streams into the streams array
But if you only want the total viewers.
var total_viewers = 0;
function getStreams(cursor) {
// snip do request
resp.data.forEach(stream => {
total_viewers += stream.viewer_count
});
// snip do paginate
}
100 per page the code checks for a cursor if it has a cursor it self calls the getStreams with the cursor
let streams = []; is hoisted outside the function as a global so would collect all streams into that array. Each call merging the results from the call into that array