PokeAPI / pokedex-promise-v2

An easy way to use pokeapi v2 with promises in node.js
MIT License
510 stars 89 forks source link

Throw errors instead of returning #2

Closed SomeoneWeird closed 8 years ago

SomeoneWeird commented 8 years ago

I was expecting something like

pokedex.getPokemonByName("oweufnwoeindq");

to reject, not resolve, as it probably should if you're using promises.

This changes it so if you get a non-200 status code, or the request fails all together, it will reject the promise instead of resolve it. Probably requires a major version bump.

Edit: pokeapi is timing out for me at the moment, so I can't run the tests locally :(

tasadurian commented 8 years ago

Good stuff! I just looked through the tests. It looks like two of them are failing because of a change the pokeapi team made to the actual api. I am going to merge this, fix the api issue, write a few more tests, then publish a new version. Thanks for catching this!