Twitch.tv API i cannot get online offline thing to work (my if statement not working.) *FIXED

Twitch.tv API i cannot get online offline thing to work (my if statement not working.) *FIXED
0

#1

i need help !!
https://wind-bow.glitch.me/twitch-api/streams/
i wrote if stream !== null return online else return offline and even if stream is not null it will return offline. :frowning:


#2

Hey. I’ll give you an hint on this one. I’ve added a bunch of console.log in your code; replace the first part of your forEach with the one shown below (I changed nothing, just added the console.log(s)). Then, see if you can understand what’s wrong with your code by looking at what they print out in your console (F12 to open the Dev Tools):

  users.forEach(function(user, i){
    console.log("%cIteration n."+i, "color:darkgrey");
    // Stream online or offline JSON null=offline
    stream = urlStream + user;
    console.log("stream  = urlStream + %c"+user, "color:#842e2e;");
    // getting channel info JSON
    channel = urlChannel + user;
    console.log("channel = urlChannel + %c"+user, "color:#2e4084;"); 
    
  console.log("%cGetting Channel: ", "color:#2e4084;", channel); 
  i === users.length-1 ? console.log("%cLoop done!"+" %cBut... wait a minute.", "color:green;", "color:grey;") : '';
  $.getJSON(channel, function(data){
  console.log("%cGetting Stream: ", "color:#842e2e;", stream);
    $.getJSON(stream, function(stat){

#3

Thanks dude. that certainly helps alot !!! :joy: