Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hack to fix pokeapi bug not working #10

Open
renecatharsis opened this issue Feb 28, 2020 · 1 comment
Open

Hack to fix pokeapi bug not working #10

renecatharsis opened this issue Feb 28, 2020 · 1 comment

Comments

@renecatharsis
Copy link

There's a workaround in PokeAPI\Client class to address this open issue:
https://github.com/PokeAPI/pokeapi/issues/345

That workaround doesn't work correctly for me, either.
Possibly because my local pokeapi installation doesn't run on localhost but a custom hostname.
It does try to resolve the expected Collection by calling the falsely delivered URL but doesn't prepend the baseUrl properly.

My (also ugly) fix for this was to replace:

if ($uri === Pokemon::POKEAPI_ENDPOINT && isset($data['location_area_encounters'])) { 
    $data['location_area_encounters'] = $this->fixEncounters($data['location_area_encounters']);
}

with

if ($uri === Pokemon::POKEAPI_ENDPOINT && isset($data['location_area_encounters'])) {
    $prepend = str_replace('/api/v2/', '', $this->baseUrl);
    $data['location_area_encounters'] = $this->fixEncounters($prepend . $data['location_area_encounters']);
}
@renecatharsis
Copy link
Author

See PR #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant