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

Requests : handle invalid "successful" responses #62

Merged
merged 2 commits into from
May 31, 2020
Merged

Requests : handle invalid "successful" responses #62

merged 2 commits into from
May 31, 2020

Conversation

nicolsc
Copy link
Contributor

@nicolsc nicolsc commented May 19, 2020

Fails graciously when

  • HTTP >= 400
  • No ads in the JSON body

Instead of a TypeError while trying to parse jsonResult.ads

(Thanks a lot for the API wrapper!)

Reject promise if status code is >= 400, or if no 'ads' entry in the JSON result.

This way it fails nicely instead of a `TypeError: Cannot read property 'ads' of undefined`
previous commit was using String, while the default error rejection is using an Error
@tdurieux tdurieux merged commit bb8ec20 into tdurieux:master May 31, 2020
@tdurieux
Copy link
Owner

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants