react-native-ssl-pinning
react-native-ssl-pinning copied to clipboard
Error handling empty responses in `.json()`
When the response body is empty aka response.bodyString === ''
then calling response.json()
does cause an Unexpected end of json
error, since apparently this function cannot handle this edge case.
Reproduction:
- Simple Endpoint that returns some json body -> everything works
- Simple endpoint that returns nothing (not even an empty json object
{}
-> Unexpected end of json` error
a simple workaround for now is response.bodyString.length > 0 ? await response.json() : {}
, but that should not be the intended use. I suggest doing a check at the beginning of this json
function