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
While migrating an app to ohmyfetch, one assertion on my test suite started to fail on a rather surprising way: the library return "" for responses with empty body (e.g. typical DELETE responses) instead of null or undefined.
If I follow the documentation, I can see why: the library will try to parse the response as JSON as default and, if it fails, as string. Them a body with length == 0 is parsed as an empty string.
While I can understand this behavior, it sounded counter-intuitive to me to return some value if the server intended to return nothing.
If you think this is by-design and not a bug, feel welcome to close it.
The text was updated successfully, but these errors were encountered:
Hi @leopiccionia. Nice spot! You can directly respond null to get native null as the result. But i think we can improve the behavior. Do you mind to share exact curl -Iv [URL] output of your API? What are Content-Type and Content-Length for API routes?
While migrating an app to
ohmyfetch
, one assertion on my test suite started to fail on a rather surprising way: the library return""
for responses with empty body (e.g. typicalDELETE
responses) instead ofnull
orundefined
.If I follow the documentation, I can see why: the library will try to parse the response as JSON as default and, if it fails, as string. Them a body with length == 0 is parsed as an empty string.
While I can understand this behavior, it sounded counter-intuitive to me to return some value if the server intended to return nothing.
If you think this is by-design and not a bug, feel welcome to close it.
The text was updated successfully, but these errors were encountered: