My project entails utilizing two AJAX requests
The first request loads all the streams
The second request retrieves information about online streams
Due to lack of combined data from APIs for both online and offline streams,
I have successfully loaded all streams with names and logos
If a stream is online, I aim to make changes to the stream div (add status, change background color to green)
This is what I attempted
List of streamers:
var streamer = ["Thulz","ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "habathcx", "RobotCaleb", "noobs2ninjas","Rakin"];
A for loop that fetches each streamer, with the first AJAX fetching each streamer's information and placing them in individual divs, while I struggle with the second part
for(i=0;i<streamer.length;i++){
$.ajax({
url: "https://wind-bow.glitch.me/twitch-api/channels/"+streamer[i],
success: function(response) {
$("#result").append("<div class='row streams'><div class='col-12 imag'><img src='"+response.logo+"' alt='"+response.name+"' height='75' width='75'><div class='texts'>"+response.name+"<p id='"+response.name+"'></p></div></div></div>");
}});//first AJAX
$.ajax({//second ajax
url: "https://wind-bow.glitch.me/twitch-api/streams/"+streamer[i],
success: function(online) {
if(online.stream !== null){
console.log(online.stream.channel.status);
}
}//response success
});
}//streamer for loop
Attempts made:
I assigned unique #id to each streamer and then appended the status and applied CSS changes to the streamers returned by the second request
$("#"+streamer[i]).append(online.stream.channel.status);
or
var sname= online.stream.channel.name;
$("#"+sname).append(online.stream.channel.status);
However, none of these methods worked. Seeking assistance!