-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anmol Varma
committed
Mar 31, 2020
1 parent
ca0397b
commit 6d7f2ae
Showing
4 changed files
with
321 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
// const axios = require('axios'); | ||
|
||
// const leagueId = [ | ||
// 4328, // English Premier League | ||
// 4331, // German Bundesliga | ||
// 4332, // Italian Serie A | ||
// 4334, // French Ligue 1 | ||
// 4335, // Spanish La Liga | ||
// 4344, // Portuguese Primeira Liga | ||
// 4346, // American Major League Soccer | ||
// 4351, // Brazilian Brasileirao | ||
// 4359 // Chinese Super League | ||
// ] | ||
|
||
// const API_KEY = 1 | ||
|
||
// Promise.all( | ||
// leagueId.map(async lid => { | ||
// const { data: { teams: teamList } } = await axios.get(`https://www.thesportsdb.com/api/v1/json/${API_KEY}/lookup_all_teams.php?id=${lid}`); | ||
// return teamList.map(({ strTeam, strTeamBadge }) => ({ | ||
// name: strTeam.toLowerCase(), | ||
// logo: strTeamBadge | ||
// })) | ||
// }) | ||
// ).then(parsedTeamList => console.log(JSON.stringify(Array.prototype.concat.apply([], parsedTeamList)))) | ||
|
||
const abc = require("./src/data/team-logo.json") | ||
|
||
const ans = {}; | ||
|
||
abc.map(({ name, logo }) => ans[name] = logo); | ||
|
||
console.log(JSON.stringify(ans)); | ||
const axios = require('axios'); | ||
|
||
const leagueId = [ | ||
4328, // English Premier League | ||
4331, // German Bundesliga | ||
4332, // Italian Serie A | ||
4334, // French Ligue 1 | ||
4335, // Spanish La Liga | ||
4337, // Dutch Eredivisie | ||
4344, // Portuguese Primeira Liga | ||
4346, // American Major League Soccer | ||
4351, // Brazilian Brasileirao | ||
4359 // Chinese Super League | ||
] | ||
|
||
const API_KEY = 1 | ||
let abc; | ||
Promise.all( | ||
leagueId.map(async lid => { | ||
const { data: { teams: teamList } } = await axios.get(`https://www.thesportsdb.com/api/v1/json/${API_KEY}/lookup_all_teams.php?id=${lid}`); | ||
return teamList.map(({ strTeam, strTeamBadge }) => ({ | ||
name: strTeam.toLowerCase(), | ||
logo: strTeamBadge | ||
})) | ||
}) | ||
).then(parsedTeamList => { | ||
abc = Array.prototype.concat.apply([], parsedTeamList) | ||
const ans = {}; | ||
abc.map(({ name, logo }) => ans[name] = logo); | ||
console.log(JSON.stringify(ans)); | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters