mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
Use Jax wrapper to get summoners basic info
This commit is contained in:
parent
e8aedda4fe
commit
312f7bb1a1
2 changed files with 20 additions and 14 deletions
|
|
@ -5,11 +5,11 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||||
<title>riot-vue</title>
|
<title>LeagueStats</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>
|
<noscript>
|
||||||
<strong>We're sorry but riot-vue doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
<strong>We're sorry but LeagueStats doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||||
</noscript>
|
</noscript>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<!-- built files will be auto injected -->
|
<!-- built files will be auto injected -->
|
||||||
|
|
|
||||||
|
|
@ -55,34 +55,40 @@ app.post('/api', function (req, res) {
|
||||||
console.log('API Request');
|
console.log('API Request');
|
||||||
console.log(req.body.summoner);
|
console.log(req.body.summoner);
|
||||||
console.log(req.body.region);
|
console.log(req.body.region);
|
||||||
//console.log(req.body.playerName);
|
|
||||||
console.time('all')
|
console.time('all')
|
||||||
data.region = req.body.region;
|
data.region = req.body.region;
|
||||||
data.username = req.body.summoner;
|
data.username = req.body.summoner;
|
||||||
|
|
||||||
newVersion()
|
|
||||||
|
|
||||||
data.finalJSON = {};
|
data.finalJSON = {};
|
||||||
getAccountInfos(res);
|
// getAccountInfos(res);
|
||||||
|
jax.regionName = data.region
|
||||||
|
getAccountInfosNew(res)
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Get static file from Riot API */
|
/* Get static file from Riot API */
|
||||||
app.post('/ddragon', async function (req, res) {
|
app.post('/ddragon', async function (req, res) {
|
||||||
console.log('DDragon Request');
|
console.log('DDragon Request')
|
||||||
const endpoint = req.body.endpoint
|
const endpoint = req.body.endpoint
|
||||||
const result = await jax.DDragon[endpoint].list()
|
const result = await jax.DDragon[endpoint].list()
|
||||||
res.send(result)
|
res.send(result)
|
||||||
})
|
})
|
||||||
|
|
||||||
/* Refactor with the Jax Wrapper */
|
/* Get account infos of an username - Refactor with the Jax Wrapper */
|
||||||
async function newVersion() {
|
async function getAccountInfosNew(res) {
|
||||||
jax.regionName = data.region
|
try {
|
||||||
|
const account = await jax.Summoner.summonerName(data.username)
|
||||||
const { id, accountId } = await jax.Summoner.summonerName(data.username)
|
data.summonerID = account.id
|
||||||
console.log(id, accountId)
|
data.accountID = account.accountId
|
||||||
|
data.finalJSON.account = account
|
||||||
|
getRanked(res)
|
||||||
|
} catch (error) {
|
||||||
|
console.log('username not found')
|
||||||
|
console.log(error)
|
||||||
|
res.send(null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get account infos of an username
|
// Get account infos of an username - Old version
|
||||||
const getAccountInfos = function (res) {
|
const getAccountInfos = function (res) {
|
||||||
request(`https://${data.region}.api.riotgames.com/lol/summoner/v4/summoners/by-name/${encodeURIComponent(data.username)}?api_key=${data.key}`, function (error, response, body) {
|
request(`https://${data.region}.api.riotgames.com/lol/summoner/v4/summoners/by-name/${encodeURIComponent(data.username)}?api_key=${data.key}`, function (error, response, body) {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue