Stuck on app

Hey ya’ll,

I managed to print the data from the api to html for the online users however, the rest of the info for the users in the array are not displaying. I’ve checked the forums and some youtube tutorials to help me with this challenge so there’s bits and pieces of codes that may look familiar. Any constructive criticism would help. Thank you!

It appears as though there is little info for streams if the user is not currently live streaming. For example, I simply typed in the api call into the browser for OgamingSC2 [] and got this as a response:

{"stream":{"_id":26119435280,"game":"StarCraft II","viewers":192,"video_height":720,"average_fps":60.0282485876,"delay":0,"created_at":"2017-08-27T21:01:40Z","is_playlist":false,"stream_type":"live","preview":{"small":"","medium":"","large":"","template":"{width}x{height}.jpg"},"channel":{"mature":false,"partner":false,"status":"MASTER'S COLISEUM 2017","broadcaster_language":"fr","display_name":"OgamingSC2","game":"StarCraft II","language":"fr","_id":71852806,"name":"ogamingsc2","created_at":"2014-09-24T15:06:58Z","updated_at":"2017-08-28T02:34:50Z","delay":null,"logo":"","banner":null,"video_banner":"","background":null,"profile_banner":"","profile_banner_background_color":"","url":"","views":27741071,"followers":58050,"_links":{"self":"","follows":"","commercial":"","stream_key":"","chat":"","features":"","subscriptions":"","editors":"","teams":"","videos":""}},"_links":{"self":""}},"_links":{"self":"","channel":""}}

Meanwhile, I got this for storbeck []:


Judging by the API requests Root Domain URL, it is using some third-party service on top of Twitch’s main API - more than likely to keep things simple for the sake of the tutorial. ( is not associated directly with Twitch. - The native Twitch API is as the root domain.)

Otherwise, you would have to sign up for a Twitch account and request a developer key to get access to the API.

Long story short, it’s nothing wrong with your code - the third-party API call is not returning the full amount of info for all users.

Hope that helps.

1 Like

You have a few problems:

#1) The following code section is a problem:

    var game=;
    var stream=;;

If you look at your console, you will see the error message:

Uncaught TypeError: Cannot read property 'channel' of null   pen.js:19

The pen.js:19 reference mean on your Codepen’s JS line #19.

It it telling you that null doesn’t have a “channel” property. What is null? Well is, so there when you attempt to make this reference an error message in the console. You will notice you get the same number of these messages for the number of users which are not streaming.

You only need to declare var stream = above. The other three statements should be inside the code bock for the if statement.

#2) You have a typo here on the actual if statement


=! is not the same as !=

This should take care of your problems. If not, let me know when you have made your changes and someone will review your code.

1 Like

Read my post below yours.

Thanks for the clarification. I just looked at API call and saw info was incomplete. I’m not fully familiar with the requirements of the tutorial. Sorry if I caused any confusion.

Oh wow thank you so much! Everything is displaying correctly so far. If I run into any more issues I’ll update here. Thanks again!

So far the only other issue is I’m not sure how to display the logos for all existing channels regardless if they are online or offline. Other than that I think I fulfilled the requirements for the challenge. I would really appreciate if you can help with that issue.

It looks like all are displaying now.

I phrased my question weird. The example project shows the logo for channels that are online.

However, the logo is still visible if the channel is offline. For example, the freecodecamp channel logo is still visible even though it is offline.

Whereas my project, if the channel is offline, the no image placeholder would be displayed. I tried to create a new else if statement to fix that issue, but I end up with no images or logos displaying.

OK, now I understand. Let me take a look and get back with you.

OK. When a user’s stream is offline, you will not get the logo information back from the json data. The best way to get all the logos is two first make a call to the to get all the user’s info (with the logo being one of them). Next, you would make the call to the streams like you currently do in your code. You would need to store the logo information in some way (i.e an array or an object) for use in conjunction with your forEach of your users array.

Thanks again! I’ll post here if I get confused.