박찬수

appfunctions

...@@ -17,12 +17,12 @@ function GetGameSchedule(teamID, leagueID, season, eventObj){ ...@@ -17,12 +17,12 @@ function GetGameSchedule(teamID, leagueID, season, eventObj){
17 } 17 }
18 18
19 // 입력: 리그ID, 반환: 팀 순위 19 // 입력: 리그ID, 반환: 팀 순위
20 -function GetTeamStanding(season){ 20 +function GetLeagueStanding(leagueID, season){
21 var request = require("request"); 21 var request = require("request");
22 var options = { 22 var options = {
23 method: 'GET', 23 method: 'GET',
24 url: 'https://v3.football.api-sports.io/standings', 24 url: 'https://v3.football.api-sports.io/standings',
25 - qs: {season: season}, 25 + qs: {league : leagueID, season: season},
26 headers: { 26 headers: {
27 'x-rapidapi-host': 'v3.football.api-sports.io', 27 'x-rapidapi-host': 'v3.football.api-sports.io',
28 'x-rapidapi-key': '526fc70a2e8b315e9a960ac4b4764191' 28 'x-rapidapi-key': '526fc70a2e8b315e9a960ac4b4764191'
...@@ -31,6 +31,14 @@ function GetTeamStanding(season){ ...@@ -31,6 +31,14 @@ function GetTeamStanding(season){
31 request(options, function (error, response, body) { 31 request(options, function (error, response, body) {
32 if (error) throw new Error(error); 32 if (error) throw new Error(error);
33 console.log(body); 33 console.log(body);
34 + let jsonBody = JSON.parse(body);
35 + console.log(jsonBody);
36 + console.log(jsonBody.response[0]);
37 + console.log(jsonBody.response[0].league);
38 + for(var i = 0; i < 20; i++){
39 + console.log(jsonBody.response[0].league.standings[0][i].rank + "|" + jsonBody.response[0].league.standings[0][i].team.name);
40 + }
41 +
34 }); 42 });
35 } 43 }
36 44
...@@ -122,4 +130,6 @@ function GetTeamStanding(teamID, season){ ...@@ -122,4 +130,6 @@ function GetTeamStanding(teamID, season){
122 if (error) throw new Error(error); 130 if (error) throw new Error(error);
123 console.log(body); 131 console.log(body);
124 }); 132 });
125 -}
...\ No newline at end of file ...\ No newline at end of file
133 +}
134 +
135 +GetLeagueStanding(39, 2021);
......