Toggle navigation
Toggle navigation
This project
Loading...
Sign in
허연우
/
FindMe.GG
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
LIANG XIAOTONG
2022-11-25 00:10:38 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c216e915a478c84ed50800bde162c9388f84909f
c216e915
1 parent
cef00772
api interface all complete
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
8 deletions
RUTROLL/router/main.js
RUTROLL/views/index.ejs
RUTROLL/router/main.js
View file @
c216e91
...
...
@@ -9,7 +9,7 @@ module.exports = function (app) {
});
app
.
get
(
'/search/:username/'
,
function
(
req
,
res
)
{
//
롤
api url
//
tft
api url
const
summonerName
=
req
.
params
.
username
;
var
nameUrl
=
`https://kr.api.riotgames.com/tft/summoner/v1/summoners/by-name/
${
summonerName
}
?api_key=
${
apikey
}
`
request
(
nameUrl
,
function
(
error
,
response
,
body
)
{
...
...
@@ -27,13 +27,42 @@ module.exports = function (app) {
const
leagueUrl
=
`https://kr.api.riotgames.com/tft/league/v1/entries/by-summoner/
${
summonerId
}
?api_key=
${
apikey
}
`
;
request
(
leagueUrl
,
function
(
error
,
response
,
body
)
{
const
info_league_json
=
JSON
.
parse
(
body
);
console
.
log
(
'league'
,
body
);
res
.
render
(
'index'
,
{
title
:
req
.
params
.
username
,
error_message
:
false
,
c_summoner
:
summoner
,
c_leagueList
:
info_league_json
const
matchIdUrl
=
`https://asia.api.riotgames.com/tft/match/v1/matches/by-puuid/
${
info_summoner_json
.
puuid
}
/ids?api_key=
${
apikey
}
`
;
request
(
matchIdUrl
,
function
(
error
,
response
,
body
)
{
const
matchIdList
=
JSON
.
parse
(
body
);
console
.
log
(
'matchIds'
,
matchIdList
);
const
promiseList
=
[];
if
(
matchIdList
.
length
>
0
)
{
matchIdList
.
forEach
(
matchId
=>
{
promiseList
.
push
(
new
Promise
((
resolve
,
reject
)
=>
{
const
matchURL
=
`https://asia.api.riotgames.com/tft/match/v1/matches/
${
matchId
}
?api_key=
${
apikey
}
`
;
request
(
matchURL
,
function
(
error
,
response
,
body
)
{
const
match
=
JSON
.
parse
(
body
);
resolve
(
match
);
});
}));
});
Promise
.
all
(
promiseList
).
then
(
matches
=>
{
console
.
log
(
'matches'
,
matches
);
res
.
render
(
'index'
,
{
title
:
req
.
params
.
username
,
error_message
:
false
,
c_matchList
:
matches
,
// 게임 데이터, array
c_summoner
:
info_summoner_json
,
// 소환사, object
c_leagueList
:
info_league_json
// leagues 데이터, array
});
})
}
else
{
res
.
render
(
'index'
,
{
title
:
req
.
params
.
username
,
error_message
:
false
,
c_matchList
:
[],
c_summoner
:
info_summoner_json
,
c_leagueList
:
info_league_json
});
}
});
console
.
log
(
'league'
,
body
);
});
});
});
...
...
RUTROLL/views/index.ejs
View file @
c216e91
...
...
@@ -41,7 +41,7 @@
<
% } else { %>
<font
size=
10em
>
<strong>
<
%= c_summoner
+ "\n"%
>
<
%= c_summoner
.name + "\n"%>
<!-- 소환사 object --
>
</strong>
</font>
<table
class=
"table"
>
...
...
Please
register
or
login
to post a comment