Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express = require('express');
- var app = express();
- var async = require('async');
- var request = require('request');
- var exphbs = require('express-handlebars')
- app.engine('handlebars', exphbs({defaultLayout: 'main'}));
- app.set('view engine', 'handlebars');
- app.get('/', function(req, res) {
- var data = {};
- var name = 'Row';
- var api_key = 'RGAPI-5aeee0fb-2c02-4576-87db-b786d6ad42e3';
- var summoner = 'https://eun1.api.riotgames.com/lol/summoner/v3/summoners/by-name/'+ name +'?api_key=' + api_key;
- var ranked = 'https://eune.api.riotgames.com/api/lol/EUNE/v1.3/stats/by-summoner/23507564/summary?season=SEASON2017&api_key=' + api_key;
- async.waterfall([
- function(callback){
- request(summoner, function(err, response, body){
- if(!err && response.statusCode == 200)
- {
- var json = JSON.parse(body);
- data.id = json.id;
- data.name = json.name;
- data.summonerLevel = json.summonerLevel;
- data.profileIcon = json.profileIconId;
- ranked = 'htt'
- callback(null, data);
- }else {
- console.log(err);
- }
- });
- request(ranked, function(err, response, body) {
- if(!err && response.statusCode == 200){
- var json = JSON.parse(body);
- if(json['playerStatSummaries'][6].playerStatSummaryType == 'RankedSolo5x5'){
- data.queueType = 'Ranked Solo';
- data.rankedWins = json['playerStatSummaries'][6].wins;
- data.rankedLosses = json['playerStatSummaries'][6].losses;
- var wins = json['playerStatSummaries'][6].wins
- var losses = json['playerStatSummaries'][6].losses;
- var games = Number(json['playerStatSummaries'][6].wins) + Number(json['playerStatSummaries'][6].losses);
- var winRatio = (Number(wins) / Number(games));
- data.winPercent = Math.round(winRatio * 100) + '%';
- var lossRatio = (Number(losses) / Number(games));
- data.lossPercent = Math.round(lossRatio * 100) + '%';
- }
- }else {
- console.log(err);
- }
- });
- }
- ],
- function(err, data) {
- if(err) {
- console.log(err);
- return;
- }
- res.render('index', {
- info: data
- });
- });
- });
- var port = Number(process.env.PORT || 3000);
- app.listen(port);
- ----
- <img src="http://opgg-static.akamaized.net/images/profile_icons/profileIcon{{{info.profileIcon}}}.jpg" alt="">
- <br>
- Summoner Name: {{{info.name}}} <br>
- Summoner Level: {{{info.summonerLevel}}} <br>
- Summoner ID: {{{info.id}}}<br>
- Wins: {{{info.rankedWins}}} <br>
- Losses: {{{info.rankedLosses}}} <br>
- Win Percent: {{{info.winPercent}}} <br>
- Loss: Percent: {{{info.lossPercent}}} <br>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement