return empty body correctly

This commit is contained in:
2023-03-05 16:58:34 +10:00
parent 937b70e1fd
commit dca56831af

View File

@@ -164,7 +164,7 @@ export const api = {
fetch(url, fetchOptions)
.then(async (response) => {
let data: string | object = "";
if (fetchOptions.method.toLowerCase() != "delete") {
if (response.headers.get("content-length") !== "0") {
if (
response &&
response.headers.get("content-type") == null
@@ -174,9 +174,13 @@ export const api = {
? await response.json()
: {};
} catch (error) {
try {
data = response.text
? await response.text()
: "";
} catch (error) {
data = "";
}
}
} else {
data =