Twitch API help: Returning undefined

For some reason, when I call the twitch API, the first item I call each time I run my program returns a link which looks like https://api.twitch.tv/kraken/channels/undefined. All subsequent calls to the API during that run return an expected result, but for some reason the first one does not. It doesn’t matter what I put in the first slot, I always get this “undefined” URL. Of course I can add a nonsense streamer in the first slot and filter it out from the result, but that’s a work around, not a solution. Can anyone explain to me why this is happening?

In your getStatus function, if you put a

console.log(streamer);

right before the following line

	$.getJSON(streamURL + streamer, function(status) {

you will see that the first time getStatus is called, streamer is undefined.

Got it! thanks mate! Now I feel dumb for not catching that… :confused: