Twitch Tv Project!

Twitch Tv Project!
0

#1

Hello guys, i am doing the twitch tv project, but can i ask you how to assign the values of the array into the api variables? Here is my code until now and what i am trying to do:

$(document).ready(function(){

const twitchChannels = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"]

var api1 = "https://wind-bow.gomix.me/twitch-api/users" + twitchChannels[i]
var api2 = "https://wind-bow.gomix.me/twitch-api/channels" + twitchChannels[i]
var api3 = "https://wind-bow.gomix.me/twitch-api/streams" + twitchChannels[i]

$.getJSON(api1, function(data1){
    for (i = 0; i < twitchChannels.length; i++){
        alert(data1.name);
    }

})//json1 end

});//end


#2

You misplaced your for loop. Your $.getJSON call should be inside for loop, not other way around.

You need to iterate over your twitchChannels array. So first, get rid of + twitchChannels[i] part from all of your api1, api2 and api3.

Then run a loop like

for(var i=0; i < twitchChannels.length;i++){
  $.getJSON(api1 + twitchChannels[i], function(data1){
    alert(data1.name);
 });
}

#3

i tried this, but it doesnt respond my calls to test it, i dont know if it sth wrong with the api or not :confused:


#5

https://codepen.io/Stivi7/pen/prwbEv?editors=1011 this works in code pen but in my local project not!


#6

now it works, ill try it this way with get json, thank u for glitch.me thing


#7

Can i ask you one more question? https://codepen.io/Stivi7/pen/prwbEv?editors=1011 i want to put the icons in the side as a column under logo but im not figuring it out! can u give me a tip?


#9

Thanks, ill try to finish the project tomorrow, you have been a great help :slight_smile:


#10

hi again, i made this for on this https://codepen.io/Stivi7/pen/prwbEv?editors=1011 but want to make the icons and the descriptions to stay inline with each other and also the status check is always offline, i think the if statement is ok, can you take a look please?