MegaChoi / Pokemon-Dex

1 stars 0 forks source link

Function fetch pokemon basic info #1

Open MegaChoi opened 1 month ago

MegaChoi commented 1 month ago

fetching initial pokemons in optimized way reduce initial loading time

Related issues : fetching amount too large If fetch using types API then there are just too many pokemons to handle because this includes ALL pokemons

Solution:

AC fetch around 16 pokemons every time limit exceeded

Technical details:

v2/pokemon should include { abilities[], form[name] location_area_encounters, base_experience:'', sprite[], this is where the image is moves[], stat[], types[], weight }

1) function fetch pokemon basic info For main pokemon array, a pokemon should only include { name, image gif, type, and a url of that pokemon} for the url part just use the prefix link with for loop index

2) function fetch pokemon stats this url is used later on when more info

fetch from id 200 to 500 https://pokeapi.co/api/v2/pokemon-species/?offset=199&limit=301

MegaChoi commented 1 month ago

issues fetch with v2/pokemon only returns names

if want basic stats like types then must either use type api or fetch full of that individual pokemon

approach : use type api and hard code image gif url

technical detail

use for loop to go through all types then only search until the limit index

MegaChoi commented 1 month ago

change of mind, this approach takes too long to load keep a record of the first 649 pokemons in json and continue to load anything else aftewards

json includes id name type

MegaChoi commented 1 month ago

finished first 649 pokemon json : [ id, name, types[ ]]

Now create a method that initially load this 649