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

Surface response status code #6

Open
nonword opened this issue Feb 2, 2018 · 0 comments
Open

Surface response status code #6

nonword opened this issue Feb 2, 2018 · 0 comments

Comments

@nonword
Copy link
Member

nonword commented Feb 2, 2018

Need to come up with a way of resolving statusCode (and perhaps other response metadata) when returning. Currently, the response handling checks for 401 but otherwise resolves the response body if it's truthy regardless of statusCode.

https://github.com/NYPL-discovery/node-nypl-data-api-client/blob/master/lib/client.js#L272-L287

This means that if an endpoint responds with a truthy response body but also flags it as http status 5xx, the client resolves it the same as any 200 response. Conventionally we tend to return the statusCode as part of the body, which means we tend to be able to detect these situations, but not all endpoints can be expected to follow that.

We should probably reject if statusCode > 400. Alternatively (or in addition) we could resolve a plain object with body and response properties (the latter holding the raw response with all metadata) and leave it up to the integrator to check response.statusCode.

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