-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
74 lines (58 loc) · 1.69 KB
/
main.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
63
64
65
66
67
68
69
70
71
72
73
74
import { createPokemonCard } from "./class-object/pokemonCard";
import {
fetchData,
fetchDataSingleParam,
fetchDataDoubleParam,
} from "./helpers/fetchData";
import {
headerBuilder,
randomCategoryBuilder,
randomHeroBuilder,
PokemonViewBuilder,
returnTop,
} from "./html-builder/htmlBuilder";
import "./styles/style.css";
import "./styles/hero-section-styles.css";
import "./styles/view-styles.css";
import "./styles/category-styles.css";
const app = document.getElementById("app");
async function main() {
const pokemonView = PokemonViewBuilder();
app.appendChild(pokemonView.pokemonView);
const pokeListData = await fetchData(
"https://pokeapi.co/api/v2/pokemon?limit=151&offset=0"
);
//console.log(pokeListData);
const pokeListDetails = await fetchDataSingleParam(
pokeListData.results,
"url"
);
//console.log(pokeListDetails);
const pokeSpeciesData = await fetchDataDoubleParam(
pokeListDetails.results,
"species",
"url"
);
//console.log(pokeSpeciesData);
const pokeEvolutionData = await fetchDataDoubleParam(
pokeSpeciesData.results,
"evolution_chain",
"url"
);
console.log(pokeEvolutionData);
const pokemonCardList = createPokemonCard(
pokeListDetails.results,
pokeSpeciesData.results,
pokeEvolutionData.results
);
randomHeroBuilder(app, pokemonCardList, pokemonView);
app.appendChild(headerBuilder(pokemonCardList, pokemonView));
// pokemonCardList.forEach((element) => {
// const card = cardBuilder(element);
// app.appendChild(card);
// });
randomCategoryBuilder(app, pokemonCardList, pokemonView);
//pokemonView.updateView(pokemonCardList[3]);
app.appendChild(returnTop());
}
main();