Hello there guys, first of all I would like to start for thanking you for taking some of your time for me and helping me out if you can.
So I’m new to coding and I would like to add multiple twitch channel statuses to my website.
Basically if someone is online it says “ONLINE” if some of them is offline it says “OFFLINE”.
You require the use of an oAuth token to call helix with.
Which (generally speaking) will require a backend server in order to make the helix call whilst protecting your secrets.
A front end would call a backend and the backend then generates or uses and existing token to lookup streams.
A “pure” front end example, like what you linked, only works if you ask the user to login vai Implict Auth in order to make calls to Twitch.
But this generally you don’t want to do, since users don’t want to have to login to use your site first.
Your code doesn’t work because you’re adding &callback=? to the end of it for some reason, which isn’t a valid param and the question mark at the end is malforming the querystring.
Additionally, you’re not sending the v5 header so the endpoint defaults to v3 which doesn’t exist any more and has long since been deprecated (just as v5 will be in the near future as it’s already marked as deprecated, which is why is why you’ve been encouraged to use Helix).
If you logged the body of the response you would have seen error messages indicating all of this
And how could I fix this for now with the v5 header? Because it would be fine for me for now and I will figure out the helix later when the kraken is discontinued in February.