-
Notifications
You must be signed in to change notification settings - Fork 0
Description
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.