Problem in Twitch Project

Currently, I am building Twitch.tv project and I ran into a problem.
Problem: online users are shown twice, both as offline and online. I am using true/false flag streaming to do it only once though it seems to perform codes both for online and offline.

here is my project:

The callback function that you pass to the “getJSON” call only gets called once it receives a proper http response. So the “if (streaming === false)” check occurs way before you set it to true for streamers that are still online. Hence, the live streamers also get processed as part of the “offline” part of your code. You can see that yourself. Just place a log to see what streamers get processed in each of your getJSON callback functions.

1 Like

You are right @anurag6. How should I get around this?