-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleagueChampionIdHelper.js
39 lines (33 loc) · 1009 Bytes
/
leagueChampionIdHelper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
export class leagueHelper {
getChampionData(championID) {
const getPatch =
axios.get('https://ddragon.leagueoflegends.com/realms/na.json')
.then((response) => {
const patchData = response.data;
for(const [key, value] of Object.entries(patchData)) {
if(key == "v"){
const currentPatch = value;
return currentPatch;
}
}
})
.catch((error) => {
console.log(error);
})
getPatch.then((patch) => {
axios.get('https://ddragon.leagueoflegends.com/cdn/' + patch + '/data/en_US/champion.json')
.then((response) => {
const championList = response.data.data;
for (const [id, value] of Object.entries(championList)) {
if (value.key == championID) {
const outputResolvedData = value;
return outputResolvedData;
}
}
})
.catch((error) => {
console.log(error)
})
})
}
}