I am using twitch api json files with javascript functions and I wanted to see if I could write an if else statement with a part of the json file being tested. Here is the link to the json file.
So now that we have the json file let me explain what I want it to do. I want to select the "stream" part of the json file and want to test it in a javascript. If "stream" == null then say Offline but if "stream" != nul then say online.
Here is the function I have so far:
$.getJSON("https://api.twitch.tv/kraken/streams/"+ twitchName +".json?callback=?", function(c){
if (stream == null) {
document.getElementById("live").innerHTML="Offline";
};
else{
document.getElementById("live").innerHTML="Online";
}
});
What am I doing wrong? Can someone please help? Thanks.
if(c.stream ==null)...cis the response object as you have defined it in callback