$(document).ready(function() {
var streamers = ["freecodecamp", "OgamingSC2", "cretetion", "ESL_SC2", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
var status;
for (var i = 0; i < streamers.length; i++) {
var url = "https://wind-bow.glitch.me/twitch-api/streams/" + streamers[i];
$.getJSON(url, function(data) {
if (data.stream === null) {
status = "Offline";
var url2 = "https://wind-bow.glitch.me/twitch-api/channels/" + streamers[i] + "";
$.getJSON(url2, function(data2) {
$("#container").append('<div class="row"><div class="col-sm-4"><img class="img-circle img-responsive" src="' + data2.logo + '"></div><div class="col-sm-4"><h2>' + data2.name + '</h2><p></div><div class="col-sm-4"><h2>' + status + '</h2></div></div><hr>');
});
} else {
console.log(data);
}
});
}
});
for循環不適用於索引我的JSON URL。此外,是否有任何有效的做法,而不是使用兩個getJSON請求?爲什麼我的for循環不能用於索引我的JSON URL?