I need to get 8 JSON from 8 different URL. I stored the query string that I have to change in an Array and I loop through it with a for loop. Here is my code:
var index = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
var request = new XMLHttpRequest();
for (var i = 0; i < index.length; i++) {
var url = "https://wind-bow.glitch.me/twitch-api/channels/" + index[i];
request.open("GET", url);
request.onload = function() {
var data = JSON.parse(request.responseText);
console.log(data);
}
request.send();
}
So far I just want to display each JSON on the console. I don't get any error but I can display only the last JSON with the last index item (noobs2ninjas).
Could anybody explain me why? how do I get the all JSON that I need?
Thanks