Twitch API-- Accessing Logo Offline

Twitch API-- Accessing Logo Offline
0.0 0

#1

Hi, I am almost done with my Twitch API Project, but I don’t understand how the example codepen was able to get the FreeCodeCamp Logo to display even when FCC is offline.

The Twitch API documentation seems to indicate that, when a channel is offline, the api returns{ "stream":null }
which I would think would make data.stream.channel.logo return an error. However, the example codepen seems to be able to access this property even when offline.

Thanks!


#2

If you look at the code again, you will notice a second $.getJSON to get the logo image using the channels endpoint instead of the streams endpoint as the first $.getJSON uses.


#3

Thanks! That makes a lot of sense.