So i’m working on my twitch api project for free code camp and am just wondering if there’s a better way to utilize the twitch api… currently I am making a separate call to the api for each user in my twitchUsers array. Is there a better way?
var twitchUsers = ["freecodecamp", "storbeck", "terakilobyte", "habathcx", "RobotCaleb", "thomasballinger", "noobs2ninjas", "beohoff", "CapcomFighters"];
var $main = $('main');
$(function() {
$.each(twitchUsers, function(index, user) {
$.getJSON(`https://api.twitch.tv/kraken/streams/${user}?callback=?`, function(twitch) {
if (twitch.stream) {
$main.append(`<p>${user} is currently streaming ${twitch.stream.game}.</p>`);
} else {
$main.append(`<p>${user} is offline.</p>`);
}
});
})
})