Calrification on the Twitch TV API chellenge

Calrification on the Twitch TV API chellenge
0

#1

Hi Everyone,

I have a question on the Twitch TV project. Actually I am using the Twitch API V5 and the thing about it is that it return details only about the channels that are streaming live.
For the rest of the channels, nothing is the returned in the API response.

So my question is, should hard code the channels and update them according to what the API response or should I do the whole challenge differently??

Thanks for your help


#2

This is entirely up to you, of course. I think that when I did this challenge I used two separate endpoints on the Twitch API. If the channel wasn’t streaming live, I would call up the other endpoint and request that channel’s information, then display it on the view with something like “OFFLINE.”

Hard coding it might also be a possibility, but it depends on what it is you’re hard coding. Suppose something in that channel’s information changes? You’d have to keep track of all the changes that are being made to all the channels and edit your code consistently.


#3

@garroadran thanks for your response. Actually I had the idea to have like an “empty” <div> and dinamically fill it after the API response. But when I saw the JSON response I was surprised. No info about offline channel at all. So with my approach I’d have only two or three channel in my list.

So what I mean by hard coding is that, I’ll have my page of all channel and update the channel status and info according to the API response. If I have a response about a channel it means it’s streaming live, else it is offline.

And when I tried to replace the https://api.twitch.tv/kraken by the end point shared by freeCodeCamp, I am getting a CORS error :frowning:

image


#4

Well, what you are describing seems to fit the requirements for the challenge very nicely, so that should do the trick!

As for the CORS error, you have probably already googled this, but this error generally pops up when you are trying to access some server resource from a local computer. Where are you developing your app? If possible, working on something like Codepen, c9 or Glitch can help you to avoid those kinds of errors.

The following Pen seems to have no problem getting data from the FCC endpoint.


#5

Okay then, I’m not wrong in my approach of the project :slight_smile:

Actually I tried with codepen and it seems to work but my request was wrong as in the instructions

so I changed only the endpoint but the request is slightly different also, so that created a lil bit of confusion to me.

Thanks for your help :slight_smile: