Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오원석
/
StarCraft2 Build Recommendation
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
신기성
2018-12-13 09:09:01 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9c9119aae14300ebd7027ccfa2aa4c2db6b69626
9c9119aa
1 parent
727e428d
API url 수정
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
router/main.js
router/main.js
View file @
9c9119a
...
...
@@ -98,7 +98,7 @@ res.render('example.ejs',{data:test});
//console.log(`${profileID}`);//테스트용 : profileID 출력
var
match_history_1
=
"https://kr.api.blizzard.com/sc2/legacy/profile/3/1/"
//매치히스토리 url 앞부분
var
match_history_2
=
"/matches?access_token=US
0q3wV6W1fIYZmRnEBbNvUrRHYZhwANIi
"
//매치히스토리 url 뒷부분
var
match_history_2
=
"/matches?access_token=US
115TlhyMaYe3d3v4t6j17Umw1CfsvCIV
"
//매치히스토리 url 뒷부분
var
match_history_url
=
match_history_1
+
profileID
+
match_history_2
;
//매치히스토리 url 구성
console
.
log
(
match_history_url
);
//테스트용 : 매치히스토리 url 출력
...
...
@@ -106,7 +106,7 @@ res.render('example.ejs',{data:test});
if
(
error
){
throw
error
};
//에러처리
console
.
log
(
'request3 processing'
);
//테스트용 : request 작동여부 출력
var
obj1
=
JSON
.
parse
(
body
);
//request 결과를 JSON object로 변환
var
obj1
=
JSON
.
parse
(
body
);
//request 결과를 JSON obje
r
ct로 변환
//console.log(obj.matches [0].map);//테스트용 : 하나에 접근
$
(
obj1
.
matches
).
each
(
function
(
index
,
match
){
//body에서 각각의 배열요소 match들과 인덱스 사용
if
(
match
.
type
==
'1v1'
){
//경기타입이 1대1인 경우에만 관심있다.
...
...
@@ -115,28 +115,30 @@ res.render('example.ejs',{data:test});
});
//each function 종료
var
ladder_1
=
"https://kr.api.blizzard.com/sc2/legacy/profile/3/1/"
var
ladder_2
=
"/ladders?access_token=US
0q3wV6W1fIYZmRnEBbNvUrRHYZhwANIi
"
;
var
ladder_2
=
"/ladders?access_token=US
115TlhyMaYe3d3v4t6j17Umw1CfsvCIV
"
;
var
ladder_url
=
ladder_1
+
profileID
+
ladder_2
;
console
.
log
(
ladder_url
);
request
(
ladder_url
,(
error
,
response
,
body
)
=>
{
//ladder request request 4
if
(
error
){
throw
error
};
console
.
log
(
'request4 processing'
);
var
obj2
=
JSON
.
parse
(
body
);
//request 결과를 JSON object로 변환
//console.log(body);
// console.log(obj2.currentSeason [2].ladder[0].wins);//테스트용 : 하나에 접근
var
wins
=
obj2
.
currentSeason
[
2
].
ladder
[
0
].
wins
;
var
losses
=
obj2
.
currentSeason
[
2
].
ladder
[
0
].
losses
;
var
wins
=
obj2
.
currentSeason
[
3
].
ladder
[
0
].
wins
;
var
losses
=
obj2
.
currentSeason
[
3
].
ladder
[
0
].
losses
;
win_rate
=
wins
/
(
wins
+
losses
);
//console.log(wins);
//console.log(losses);
//console.log(win_rate);
var
profile_1
=
"https://kr.api.blizzard.com/sc2/legacy/profile/3/1/"
;
var
profile_2
=
"?access_token=US
0q3wV6W1fIYZmRnEBbNvUrRHYZhwANIi
"
;
var
profile_2
=
"?access_token=US
115TlhyMaYe3d3v4t6j17Umw1CfsvCIV
"
;
var
profile_url
=
profile_1
+
profileID
+
profile_2
;
console
.
log
(
profile_url
);
request
(
profile_url
,(
error
,
response
,
body
)
=>
{
//profile request request 5
if
(
error
){
throw
error
};
console
.
log
(
'request5 processing'
);
//console.log(body);
var
obj3
=
JSON
.
parse
(
body
);
//request 결과를 JSON object로 변환
//console.log(obj2.currentSeason [1].ladder[0].wins);//테스트용 : 하나에 접근
primary_race
=
obj3
.
career
.
primaryRace
;
...
...
Please
register
or
login
to post a comment