blakejoy / tmdb-ts

Typescript client wrapper for TheMovieDB (TMDB) v3
MIT License
37 stars 12 forks source link

Types do not include errors #47

Closed lucassardois closed 4 months ago

lucassardois commented 6 months ago

Describe the bug API endpoint are typed without reflecting potential errors. This is an issue since HTTPs errors (400+) do not reject promise but instead resolve them with an object not matching the type.

To Reproduce Executing the following code will return an object not matching the type because TMDB send a 401 request with a descriptive error.

new TMDB('wrongApiToken').account.details()

Expected behavior The previous code should either reject in case of error (ex: when the API token is unauthorized), or include the type error in the resolved type.

Desktop (please complete the following information):

blakejoy commented 5 months ago

Just pushed an implementation for handling api errors. Let me know if that works. @lucassardois v1.6.1

blakejoy commented 5 months ago

Hmmm I guess would you rather the whole response object or just the response?