Closed jeremy-jtlo closed 2 years ago
This looks good, it did break some functionality in that ability names are using the given name and not the localized name. But that's another issue since I kind of hacked it together, I'll create a new issue for it and create a unit test for it
Removed a small thorn from
PokemonDisplay.tsx
. As a view class, it really has no business trying to create DTOs. For this first pass fix, the service now performs the fetch and uses the factory to return a proper DTO, as it should have done in the first place.The
getPokemon
method in the service was a simple fetch + dump of raw JSON. Because of ESLint, that's now been converted to anasync
function.In order to maintain class context I've changed the declaration to an arrow function (some more details on that here and here.)
If the get method was declared in this style:
public getPokemon(url: string) { ... }
Then the inside of the method would say
this
isundefined
. It's been converted to an arrow:public getPokemon = async (url: string) => { ... }
And now it remembers its class properties.