So, I'm using nodejs to parse json, and I'm wanting to get an object that's an array and use the values in a for each loop.
JSON I'm getting: http://tmi.twitch.tv/group/user/loneztar/chatters
var cronUsers = client.utils.cronjobs('1 * * * * *', function() {
console.log('API Test');
console.log('Response from Twitch Chat:');
request('http://tmi.twitch.tv/group/user/loneztar/chatters', function (error, response, body) {
if (!error && response.statusCode == 200) {
data = JSON.parse(body);
console.log(data.chatters.viewers);
//for each string in the viewers
}
})
});
Above is the code I'm using to retrieve the data. And when I log to the console I get the following (at time of asking):
[ 'duckziller72',
'adanaran',
'nyckeln',
'diabolicalsheep69',
'audery101',
'gone_nutty',
'k4unl',
'eidokan',
'mattesolo',
'siland',
'nullvoid8',
'troy00114',
'sixdev',
'jake_evans',
'doctoranguus',
'juicegraip',
'k4rush' ]
Now I want to use each of them strings in a for each loop. I've tried using the data var I'm using but I can't get anything working. Would appreciate some help! Feel free to ask for other stuff, I'll happily edit.