Hi everyone,
I just started using the twitch kraken api and I have a few questions. Whenever I attempt to get the json object
there is no response. I am attempting to run this function through amazon aws lambda, and don’t have access to a console. In the code below my callback function will always print out “SUCCESS got streamers ERROR”. I am pretty certain right now the “ERROR” comes from my initial setting of result. How come result does not get changed into the proper json?
BTW I have used postman and it returns the proper thing with the query and param, and headers
function getJSON(callback){
var result = "ERROR";
request.get(url(games[0]),function(error,response,body){
var d = body;
result = d.streams[0];//.channel.display_name;
// for(var i = 0; i < limit; i++){
// streamers.push(d.streams[i].channel.display_name)
// }
streamers.push(result);
});
if (streamers.length < 0){
callback("ERROR");
}else{
callback("SUCCESS got streamers " + result);
}
}
function url(game){
return {
url: "https://api.twitch.tv/kraken/streams/",
qs : {
'game' : 'overwatch',
'limit' : 2
}
headers: {
'Client-ID': clientID,
'Accept': 'application/json',
'Accept-Charset': 'utf-8',
},
json: true
};
}