Twitch.tv status

Twitch.tv status
0.0 0

#1


Why data[j] does not show data? I need to append each status to its channel but i cant.
Thank you.


#2

What do you expect from this: j < data in your for loop? data is not a number, so j < data won’t work.

If it would work, then data[j] would fail, because data is not an array, but an object. If you put console.log(data) outside of your for loop, you can check what properties are available and decide which to use.


#3

My idea was to iterate the data and append status to its name by making a loop which would list these statuses below but i cant come up to a solution… when i tried to append status to channels it always appended whole status info to one div and not a specific status to a specific channel


#4

You will have to check the JSON that is coming back from both a channel that is offline and that is online (they differ). You will see that data.stream is null for streams that are offline and it is an object with data if the stream is online. Simple usage (for inside function info(data){}:

var status = "";
        
if(data.stream !== null){
  status = "online";
}else{
  status = "offline";
}

$("#status").append(
  "<p>" + status + "</p>"
);

Always take a close look at the JSON you get and check what you need to use.