app.js
// Ajax function to return the results for third route
Ajax function to return the results for third route
Ajax function to return the results for third route
function request_playersummary(url, callback) {
	request(url, function (err, resp, body) {
		var resultsArray = [];
		body = JSON.parse(body);
		if (!body.response.players) {
			players = "No player found. Try again.";
			callback(players);
		} else {
			players = body.response.players;
			for (var i = 0; i < players.length; i++) {
				resultsArray.push({
					profileurl: players[i]["profileurl"],
					personaname: players[i]["personaname"],
					avatarfull: players[i]["avatarfull"],
					realname: players[i]["realname"],
					loccountrycode: players[i]["loccountrycode"],
					locstatecode: players[i]["locstatecode"]
				});
			};
		};
		callback(resultsArray);
	});
}
function request_playersummary ( url , callback ) { request ( url , function ( err , resp , body ) { var resultsArray = [ ] ; body = JSON . parse ( body ) ; if ( ! body . response . players ) { players = "No player found. Try again." ; callback ( players ) ; } else { players = body . response . players ; for ( var i = 0 ; i < players . length ; i ++ ) { resultsArray . push ( { profileurl : players [ i ] [ "profileurl" ] , personaname : players [ i ] [ "personaname" ] , avatarfull : players [ i ] [ "avatarfull" ] , realname : players [ i ] [ "realname" ] , loccountrycode : players [ i ] [ "loccountrycode" ] , locstatecode : players [ i ] [ "locstatecode" ] } ) ; } ; } ; callback ( resultsArray ) ; } ) ; }
Ajax function to return the results for third route
Ajax function to return the results for third route
// request module is used to process the url and return the results in JSON format // logic used to traverse through and push out data for player summary // pass back the results to client side