From 859e40ee52011ee14b4a5aee4e6b990ebbd2bcdf Mon Sep 17 00:00:00 2001 From: Mario Kreitz Date: Tue, 10 Sep 2024 10:56:02 +0200 Subject: [PATCH] Update pokemon.service.ts --- src/app/services/pokemon.service.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/services/pokemon.service.ts b/src/app/services/pokemon.service.ts index 41ec25b..f3dc42e 100644 --- a/src/app/services/pokemon.service.ts +++ b/src/app/services/pokemon.service.ts @@ -25,9 +25,19 @@ export class PokemonService { const pokemons = await Promise.all( result.map(async (pokemon) => { - const pokemonSpecies = await this.pokedex.getPokemonSpeciesByName( - pokemon.name - ); + //TODO: FIX ME + const pokemonSpecies = await this.pokedex + .getPokemonSpeciesByName(pokemon.name) + .catch(() => { + /* + Catch that stupid ass pokemon name with "-" in it + that doesn't exist in the Pokedex under Species + e.g "wormadam-plan" => "wormadam" becaus "look at me im special" + */ + const idiotPokemon = pokemon.name.split('-')[0]; + return this.pokedex.getPokemonSpeciesByName(idiotPokemon); + }); + const pokemonData = await this.pokedex.getPokemonByName(pokemon.name); return { ...pokemonData, ...pokemonSpecies }; })