I am creating a twitch chat bot with node. I need to get a list of moderators from the link http://tmi.twitch.tv/group/user/:channel/chatters I can recieve the data and parse it, but I just need to know how to return the data within the requests and save it into a variable.Here is what I have so far.
function getMods(person, chanel) {
var channel = getUser(chanel);
request('http://tmi.twitch.tv/group/user/' + channel + '/chatters', function(error, response, body) {
if (!error && response.statusCode == 200) {
var mods = JSON.parse(body);
// I want to return the value mods through the function
}
});
}
So I can call the function and store the array such as this.
var mods = getMods('xtreameprogram2', '#zero_optics');
Is it possible without using callbacks?