Front End Projects: Twitch API

Front End Projects: Twitch API
0.0 0


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(`${user}?callback=?`, function(twitch) {
      if ( {
        $main.append(`<p>${user} is currently streaming ${}.</p>`);
      } else {
        $main.append(`<p>${user} is offline.</p>`);


@raymeibaum in fact you will end up doing each query twice for the users, that is if you are going to include the user picture. One call to streams and one call to channels…


You can try:

'' + twitchUsers + '&callback='

but you need to handle the response differently because it is an array of channels that are online. Then you need to iterate through the original list you searched for in order to get the offline streamers. You need a different api call to check if any data comes back for each one. If it gives you an error, you know that it isn’t a valid channel name.