Hi everyone, I'm currently trying to build something that will display the top x amount of current live streamers for y game. I am trying use the express .get function to get the json back from twitch, but it's not working for some reason.App Info: In developing this I am simply hard coding the viewer limit to 2 and the game to overwatch.Code:getJSON(function(data){ if(data !== "ERROR"){ speechOutput = data;//capitalizeFirst(game) + " top three streamers are: " + arrayToString(streamers) + '.'; var repromptText = "Do you want to hear more about games?"; var header = capitalizeFirst(game); }else{ speechOutput = "I'm sorry, something went wrong and I could not get the streamers."; } //////////////////////Above is usage in code, below are the methods ///////////////////// function getJSON(callback){ var result = "ERROR"; request.get(url(games[0]),function(error,response,body){ console.log("requested for url: " + url(games[0])); var d = JSON.parse(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: "http://ift.tt/2tJeJpb",//twitchlimit, // qs: { // 'game' : 'overwatch', // 'limit' : 2 // }, headers: { 'Client-ID': clientID } //add qs : {game: game, limit:limit}query strings here }; }
Submitted July 12, 2017 at 08:07PM by quads_of_steel
No comments:
Post a Comment