Twitch project, API returning brunofin and comster404 as undefined?

Hi guys, I’ve finally gotten somewhere with this project. One issue I’m having is that brunofin and comster404 don’t seem to be processed through the API call. It just returns undefined. I tried experimenting and tried to get it to do a console.log with the error part of the ajax but nothing, just acts like everything is a success and brunofin and comster404 come up as undefined.

Sorry if this is badly explained, still very new to coding so I don’t know the proper terms. Heres the link to my codepen.

Thank you in advance.

http://codepen.io/jonathanpuc/pen/wdJWNp?editors=1111

Well it’s not really “failing” in that your code is failing, BUT for example look here:

https://wind-bow.glitch.me/twitch-api/channels/comster404

and at brunofin. They both come up undefined. Im not really sure of the reason for this mine actually does this as well. Maybe their channel’s have some private settings or something? But you can check the same link above for another user and it will return fine. So I don’t necessarily think this is a “code issue”

Hmm, I’ve had a look at other peoples codepens and there’s was able to still spit out the usernames while mine just says undefined. Maybe its something to do with the fact that we use a different API pass through now? “https://wind-bow.glitch.me/” versus “https://api.twitch.tv/kraken”?

I imagine maybe that could have something to do with it. Im using the wind-bow as well and have the same issue.

Im pretty sure less people use kraken because of this (see fcc project page for twitch app):

UPDATE: Due to a change in conditions on API usage explained here Twitch.tv now requires an API key, but we’ve built a workaround. Use https://wind-bow.gomix.me/twitch-api instead of twitch’s API base URL (i.e. https://api.twitch.tv/kraken ) and you’ll still be able to get account information, without needing to sign up for an API key.

They’re undefined because they’re deactivated Twitch accounts.

The first AJAX function works, but because Twitch returns undefined for inactive accounts, data1.name is undefined. So when you go to make your URL using data1.name, it gets set with undefined, which is then the user that Twitch looks for. Since there isn’t anything wrong with the network calls, the error handler won’t kick it. You have to manage what happens when Twitch returns undefined.

Oh, okay thank you! Any tips on how to go about managing that?

I assumed they were purposely added to make sure that our code can handle closed accounts:

User Story: I will see a placeholder notification if a streamer has closed their Twitch account (or the account never existed). You can verify this works by adding brunofin and comster404 to your array of Twitch streamers.

Just think about how you want to convey this information to the user. undefined could mean that the user deleted their account, but it could also mean that there was never an account in the first place. You’ve already got some code for users that aren’t found, it’s just a matter of changing your logic a bit to make use of it.