New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http.fetch always expects a reponse body #2831
Comments
By default Tauri assumes a JSON response. It should work with |
Perhaps, although this is only a workaround, but not a fix. |
Why is it a workaround if it's the API design? It might be a wrong design (we could argue that it should default to a binary response), but it's still the current design. |
Axios, for example, also uses // `responseType` indicates the type of data that the server will respond with
// options are: 'arraybuffer', 'document', 'json', 'text', 'stream'
// browser only: 'blob'
responseType: 'json', // default Yet, it won't throw an error when there is no response body, because there is no obligation for it to exist. Additionally, setting any value (like But, I must also agree that Axios' behavior does not follow what I just said, as it ignores the lack of response body when one is expected, therefore, I alternatively suggest accepting |
I see your point now, and I agree with you. |
What about a step further : |
Describe the bug
http.fetch
always expects a reponse body, therefore throws an error when there is none.To Reproduce
Steps to reproduce the behavior:
http.fetch
request that will return no response body and without definingresponseType
;Failed to parse response as JSON: SyntaxError: JSON Parse error: Unexpected EOF; try setting the responseType option to ResponseType.Text or ResponseType.Binary if the API does not return a JSON response
.Expected behavior
The request succeeds.
Platform and Versions (required):
Additional context
This error was spotted during the development of
axios-tauri-adapter-test
, the unit test project foraxios-tauri-adapter
.Stack Trace
Not applicable
The text was updated successfully, but these errors were encountered: