File tree 1 file changed +4
-1
lines changed
1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ export class PokemonDetails {
45
45
try {
46
46
const response = await fetch ( `https://pokeapi.co/api/v2/pokemon/${ id } ` ) ;
47
47
const data = await response . json ( ) ;
48
+ const response2 = await fetch ( `https://pokeapi.co/api/v2/pokemon-species/${ id } ` ) ;
49
+ const data2 = await response2 . json ( ) ;
48
50
const imageUrl = data . sprites . front_default ;
49
51
const officialArtworkUrl = data . sprites . other [ "official-artwork" ] . front_default ;
50
52
const height = data . height ;
@@ -67,9 +69,10 @@ export class PokemonDetails {
67
69
} ) ;
68
70
const damageRelations = await getPokemonDamageRelations ( id ) ;
69
71
const pokedexDescriptions = await getPokemonDescriptions ( id ) ;
72
+ const name = data2 . names . find ( ( entry : { language : { name : string } } ) => entry . language . name === 'en' ) ;
70
73
return new PokemonDetails (
71
74
id ,
72
- data . species . name ,
75
+ name ? name . name : data . species . name ,
73
76
imageUrl ,
74
77
officialArtworkUrl ,
75
78
height ,
You can’t perform that action at this time.
0 commit comments