Skip to content

Commit

Permalink
Update pokemon.service.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mariokreitz committed Sep 10, 2024
1 parent 8b95dc4 commit 859e40e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/app/services/pokemon.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
})
Expand Down

0 comments on commit 859e40e

Please sign in to comment.