Why won't my Twitch API work?

I’m doing the Twitch API challenge and as far as I can tell, there’s no API data coming through despite the link working fine?

  var api = "https://wind-bow.gomix.me/twitch-api/streams/freecodecamp";
    if (data.stream ===null){
      $('#test').html("This channel is currently OFFLINE");
      $('#test').html("This channel is currently ONLINE");

As you can see I’m using FCC’s work around API so I don’t need an API key, the link works correctly for both offline and online twitch channels. I’ve been going over the code for a while now and to my knowledge there doesn’t seem to be anything off. Am I missing something or doing something wrong? Please send help, I’m extremely confused.

Just in case the link to the full project is required for extra help: https://codepen.io/Jobo_v22/pen/NyoEGE?editors=1010

if you check the console you’ll see this error:

Failed to load https://wind-bow.gomix.me/twitch-api/streams/freecodecamp: Redirect from 'https://wind-bow.gomix.me/twitch-api/streams/freecodecamp' to 'https://wind-bow.glitch.me/twitch-api/streams/freecodecamp' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.

I recommend you to use cors-anywhere by heroku https://cors-anywhere.herokuapp.com/

1 Like

You’re using the older API. Change the URL to https://wind-bow.glitch.me/ and it will work.

1 Like

Oh my god yes!! that works!! thank you :smiley: