# Twitch Tv Project Help

**URL:** <https://forum.freecodecamp.org/t/twitch-tv-project-help/118768>\
**Category:** General\
**Tags:** help, twitch, api\
**Created:** [May 23, 2017, 2:41am UTC](https://forum.freecodecamp.org/t/twitch-tv-project-help/118768 "2017-05-23T02:41:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![WigglyWorm](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/wigglyworm/32/51619_2.png) [@WigglyWorm](https://forum.freecodecamp.org/u/WigglyWorm)\
**Post date:** [May 23, 2017, 2:41am UTC](https://forum.freecodecamp.org/t/twitch-tv-project-help/118768/1 "2017-05-23T02:41:28Z")

</div>

Hey, fellow coders!  
I need some help! I’m running into some difficulties with my twitch app.  
I can’t seem to display both online and offline data it only seems to display online at the moment.

I’ve included the link to my app below! Any solutions would be appreciated!

> **[Twitch.tv](https://codepen.io/Wiggly_Worm/pen/jmpXBz?editors=1010)**
>
> ...

---

<div class="post-metadata">

**Author:** ![Hieratikos](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hieratikos/32/46744_2.png) [@Hieratikos](https://forum.freecodecamp.org/u/Hieratikos)\
**Post date:** [May 23, 2017, 5:28am UTC](https://forum.freecodecamp.org/t/twitch-tv-project-help/118768/2 "2017-05-23T05:28:42Z")

</div>

I looked in the developer tools of chrome while your app was on codepen, and I saw the following error:

> pen.js:44 Uncaught TypeError: Cannot read property ‘game’ of null  
> at Object. (pen.js:44)  
> at i (jquery.min.js:2)  
> at Object.fireWith [as resolveWith] (jquery.min.js:2)  
> at A (jquery.min.js:4)  
> at XMLHttpRequest. (jquery.min.js:4)

Line 44 of pen.js is:

> var game = data2.stream.game;

If the stream is offline, it is coming back as null, throwing an error, and the app is then unresponsive. A fix to this would be to set up conditionals that check for a null value, then in the logic, set that stream to “offline”. Something like the following:

> ```
> $.getJSON(makeURL("streams", channel), function(data) {
> var game,
> status;
> if (data.stream === null) {
> game = "Offline";
> status = "offline";
> } else if (data.stream === undefined) {
> game = "Account Closed";
> status = "offline";
> } else {
> game = data.stream.game;
> status = "online";
> };
> 
> ```

---

<div class="post-metadata">

**Author:** ![dylan](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dylan/32/54445_2.png) [@dylan](https://forum.freecodecamp.org/u/dylan)\
**Post date:** [May 23, 2017, 5:31am UTC](https://forum.freecodecamp.org/t/twitch-tv-project-help/118768/3 "2017-05-23T05:31:59Z")

</div>

I haven’t done this project yet but on line 58 where you append the html there is

```auto
if (streamInfo === null) { ...

```

null means there is no value right. But I think what you’re after is to check if they’re on/offline.

logging out the contents of streamInfo shows objects for online streamers and null for offline. As in there is no offline info to push to your tables. which is why the console os showing typerrors for props like .game and .viewers

 ![](https://global.discourse-cdn.com/freecodecamp/original/3X/4/c/4cb2a449272d916164fe085278b2b18650531c2e.png)

Might have to figure out a different way to sort on/offline streamers. Check a status or something similar before hand.

---

<div class="post-metadata">

**Author:** ![WigglyWorm](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/wigglyworm/32/51619_2.png) [@WigglyWorm](https://forum.freecodecamp.org/u/WigglyWorm)\
**Post date:** [May 23, 2017, 7:42pm UTC](https://forum.freecodecamp.org/t/twitch-tv-project-help/118768/4 "2017-05-23T19:42:25Z")

</div>

Thank you so much for your help I was able to fix the problem!

---

<div class="post-metadata">

**Author:** ![WigglyWorm](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/wigglyworm/32/51619_2.png) [@WigglyWorm](https://forum.freecodecamp.org/u/WigglyWorm)\
**Post date:** [May 23, 2017, 8:30pm UTC](https://forum.freecodecamp.org/t/twitch-tv-project-help/118768/5 "2017-05-23T20:30:07Z")

</div>

Now I’m just a little stuck on how to make the links reveal online and offline data when clicked.

---

<div class="post-metadata">

**Author:** ![WigglyWorm](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/wigglyworm/32/51619_2.png) [@WigglyWorm](https://forum.freecodecamp.org/u/WigglyWorm)\
**Post date:** [May 23, 2017, 8:43pm UTC](https://forum.freecodecamp.org/t/twitch-tv-project-help/118768/6 "2017-05-23T20:43:33Z")

</div>

Thanks Dylan for your feedback I was able to fix that issue.

---

<div class="post-metadata">

**Author:** ![thinkC](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/thinkc/32/9092_2.png) [@thinkC](https://forum.freecodecamp.org/u/thinkC)\
**Post date:** [May 25, 2017, 7:39am UTC](https://forum.freecodecamp.org/t/twitch-tv-project-help/118768/7 "2017-05-25T07:39:33Z")

</div>

Hi Campers,

Please I need help here…when I do a console log on my offline twitch data, it comes in as undefined and the output is not able to display correctly. Please help.Here is my codepen below.  
[https://codepen.io/thinkC/pen/rmRGLG](https://codepen.io/thinkC/pen/rmRGLG)

Thanks

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:54pm UTC](https://forum.freecodecamp.org/t/twitch-tv-project-help/118768/8 "2021-01-17T20:54:17Z")

</div>


