You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered:
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 any200
response. Conventionally we tend to return thestatusCode
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
ifstatusCode > 400
. Alternatively (or in addition) we couldresolve
a plain object withbody
andresponse
properties (the latter holding the raw response with all metadata) and leave it up to the integrator to checkresponse.statusCode
.The text was updated successfully, but these errors were encountered: