mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-25 03:33:36 +03:00
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
parent
c664e9dbe0
commit
50c63900c7
5
.changes/api-fetch-empty-reponse.md
Normal file
5
.changes/api-fetch-empty-reponse.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"api": patch
|
||||
---
|
||||
|
||||
Fix `http.fetch` throwing error if the response is successful but the body is empty.
|
File diff suppressed because one or more lines are too long
@ -203,7 +203,10 @@ class Client {
|
||||
// @ts-expect-error
|
||||
response.data = JSON.parse(response.data as string)
|
||||
} catch (e) {
|
||||
if (response.ok) {
|
||||
if (response.ok && (response.data as unknown as string) === '') {
|
||||
// @ts-expect-error
|
||||
response.data = {}
|
||||
} else if (response.ok) {
|
||||
throw Error(
|
||||
`Failed to parse response \`${response.data}\` as JSON: ${e};
|
||||
try setting the \`responseType\` option to \`ResponseType.Text\` or \`ResponseType.Binary\` if the API does not return a JSON response.`
|
||||
|
Loading…
Reference in New Issue
Block a user