PokeAPI/pokebase

Root endpoint support

Closed this issue · 2 comments

I noticed root endpoints don't work for endpoints that don't have name properties for their objects, such as /machine. I talk about this in this issue at pokepy, but I'll state it again. The /machine endpoint returns this:

results: [
  0: {
    url: "https://pokeapi.co/api/v2/machine/1/"
  },
  ...
]

while the /pokemon endpoint returns this:

results: [
  0: {
    name: "bulbasaur",
    url: "https://pokeapi.co/api/v2/pokemon/1/"
  },
  ...
]

Because there's no name property, it returns None for the name here in the APIResource class.

I think I managed to fix the issue by adding this conditional after those lines:

if name == None:
  self.__dict__.update({'name': id_})

Should I open a pull request for this then?

I got a fix for this merged, does latest work for you now?

Closed due to no response.