-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadAPIs.js
62 lines (56 loc) · 1.93 KB
/
loadAPIs.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
async function loadPokemonAPI(x) {
let newvar;
if (allPokemon[x - 1] == undefined) {
if (x == 'urshifu') {
x = 'urshifu-single-strike';
}
if (x == 'darmanitan') {
x = 'darmanitan-standard';
}
let pokeUrl = `https://pokeapi.co/api/v2/pokemon/${x}`;
let pokemonResponse = await fetch(pokeUrl);
currentPokemon = await pokemonResponse.json();
newvar = currentPokemon;
} else { currentPokemon = allPokemon[x - 1]; }
return newvar;
}
async function loadPokemonSpeciesAPI(i) {
if (i == 'urshifu-rapid-strike' || i == 'urshifu-single-strike') {
i = 892;
}
if (i == 'darmanitan-standard') {
i = 555;
}
let speciesURL = `https://pokeapi.co/api/v2/pokemon-species/${i}`
let speciesResponse = await fetch(speciesURL);
currentSpecies = await speciesResponse.json();
}
async function loadPokemonTypeAPI(j, x) {
let typeURL = `https://pokeapi.co/api/v2/type/${allPokemon[x-1].types[j].type.name}/`;
let typeResponse = await fetch(typeURL);
let germanType = await typeResponse.json();
return germanType;
}
async function loadPokemonAbilityAPI(k, x) {
let abilityUrl = `https://pokeapi.co/api/v2/ability/${allPokemon[x-1].abilities[k].ability.name}/`;
let abilityResponse = await fetch(abilityUrl);
let currentAbility = await abilityResponse.json();
return currentAbility;
}
async function loadEvolutionAPI(x) {
let evoUrl = allSpecies[x - 1].evolution_chain.url;
let evoResponse = await fetch(evoUrl);
currentEvo = await evoResponse.json();
}
async function loadItemAPI(link) {
let itemUrl = link;
let itemResponse = await fetch(itemUrl);
let currentItem = await itemResponse.json();
return currentItem;
}
async function loadMove(name) {
let moveUrl = `https://pokeapi.co/api/v2/move/${name}/`
let moveResponse = await fetch(moveUrl);
let currentMove = await moveResponse.json();
return currentMove;
}