I'm currently working with the twitch.tv API and utilizing the Angular $resource factory. My goal is to access the endpoint: GET /channels/:channel. What I want to achieve is to retrieve the channel for each element within an array. I attempted using /channels/users[1], but I understand this is incorrect. Is there a way to extract the :channel information for all users in the array? Alternatively, is there a more efficient method to accomplish this task?
(function() {
angular.module('twitch', ['ngResource'])
.controller('TwitchController', ['$scope', 'TwitchAPI', function($scope, TwitchAPI) {
$scope.getAPI = function(){
var users = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
for(var i = 0; i < 8; i++){
TwitchAPI.get({channel: users.i});
}
}
$scope.online = [];
$scope.offline = [];
}])
.factory('TwitchAPI', function TwitchAPIFactory($resource){
return $resource('https://api.twitch.tv/kraken/channels/:channel', { callback: "JSON_CALLBACK" });
});
})();