Problems with the Pagination using HTTPS in Node.JS

Then


let total_viewers = [];

function getStreams(game_id, cursor) {
    // snip do request
    resp.data.forEach(stream => {
        if (!total_viewers.hasOwnProperty(game_id)) {
            total_viewers[game_id] = 0;
        }
        total_viewers[game_id] += stream.viewer_count
    });
    // snip do paginate
}

It stops the variable being used in the same scope.

So I can’t have two total_viewers in the global scope
But I could have a let total_viewers inside the function scoped to the function, but since I didn’t the global scoped one is the one affected.