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