I'm using the twitch.tv api and using the Angular $resource factory. The endpoint I'm trying to use is: GET /channels/:channel. What I'm trying to do is get the channel for each array element. I tried /channels/users[1] but I know this is wrong. How can I get the :channel for all the users in the array? Or is there a better way to do this?
(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" });
});
})();