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
If the server returns a 500 Internal Server Error, the JSON parse still happens and the error is Unexpected token I in JSON at position 0. It appears the only way around this is to not have phin parse the JSON and to do it manually after checking the statusCode.
I think it makes more sense for phin to not parse the JSON unless the statusCode is a 2xx.
The text was updated successfully, but these errors were encountered:
Fixesethanent#61
Prevents parsing body as JSON unless the status code is in the 2xx range to allow 4xx and 5xx errors to propagate without JSON parsing errors
I recall another request library (axios?) throwing a (deliberate) exception on non-success statuses.
I'm not saying that's the best way to deal with them but it is an option.
Related to #48
When a server responds with a status code of 5xx, the body should not be parsed as JSON.
If the server returns a
500 Internal Server Error
, the JSON parse still happens and the error isUnexpected token I in JSON at position 0
. It appears the only way around this is to not have phin parse the JSON and to do it manually after checking the statusCode.I think it makes more sense for phin to not parse the JSON unless the statusCode is a 2xx.
The text was updated successfully, but these errors were encountered: