Lacking in essential ajax knowledge

$(document).ready(function(){
//make sure jquery library is working
$(“p”).append(“hello world”);
//declare stream array
var twitchers=[“dmbrandon”,“MedryBW”,“ESL_SC2”, “OgamingSC2”, “cretetion”, “freecodecamp”, “storbeck”, “habathcx”, “RobotCaleb”, “noobs2ninjas”];
//declare endpoint
var endPoint=“https://api.twitch.tv/helix/streams?user_id=”+twitchers;
//declare get method

$.ajax({
//headers:"user-id:my-twitch-id ",
url:endPoint,
dataType: ‘json’,
async:false,
type:‘GET’,
username:“my-twitch-id”,
password:“my-twitch-secret”,
success: function(data){
console.log(data);
},
error:function(error){
console.log("Your ERROR is: "+ error);
}
});

});


i have been trying to figure this out and i feel that I’m messing up in the header method i believe that it is asking me to give a header with my id and secret but i really don’t get how to do that and haven’t seen how to online yet any advice on where to look, should i read up on curl?

according to Twitch documentation you need to authorise your request with a given token.
(tbh it’s a very common practice)

Pretty much you have to get the token, then add it in the header request:

$.ajax({
 type: 'GET',
 url: 'https://api.twitch.tv/kraken/channels/twitch',
 headers: {
   'Client-ID': YOUR_TOKEN
 },
[...]
})

More on an official twitch blog post

However FCC gives an alternative endpoint to the original twitch API so that you don’t have to register:
https://wind-bow.glitch.me/
Refer to the challenge for further details.

Hope it helps :slight_smile:

I’ve sort of pieced together how to do it using api v5/kraken but i wanted to do it in the new api/helix since the old one will be removed at the end of the year, and it is a little different so i havent seen a lot of documentation on this api

thank you so much for the extra information though!

According to the documentation you still need to obtain a token from Twitch, and the add it as a Bearer token in the header:

headers {
      ...headers,
      authorization: 'Bearer YOUR_TOKEN',
}