Open jdforsythe opened 3 years ago
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.
I created #75 as an alternative fix
Comments on #75 as an alternative would be appreciated. You can see my comment on that PR. I think it's a practical solution.
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.