dont attempt to decode body on DELETE method
This commit is contained in:
@@ -100,14 +100,26 @@ export const api = {
|
|||||||
fetch(url, fetchOptions)
|
fetch(url, fetchOptions)
|
||||||
.then(async (response) => {
|
.then(async (response) => {
|
||||||
let data: string | object = "";
|
let data: string | object = "";
|
||||||
if (response.headers.get("content-type") == null) {
|
if (fetchOptions.method.toLowerCase() != "delete") {
|
||||||
try {
|
if (
|
||||||
data = response.json ? await response.json() : {};
|
response &&
|
||||||
} catch (error) {
|
response.headers.get("content-type") == null
|
||||||
data = response.text ? await response.text() : "";
|
) {
|
||||||
|
try {
|
||||||
|
data = response.json
|
||||||
|
? await response.json()
|
||||||
|
: {};
|
||||||
|
} catch (error) {
|
||||||
|
data = response.text
|
||||||
|
? await response.text()
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data =
|
||||||
|
response && response.json
|
||||||
|
? await response.json()
|
||||||
|
: {};
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
data = response.json ? await response.json() : {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
@@ -125,6 +137,7 @@ export const api = {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
console.error("ie", error);
|
||||||
// Handle any errors thrown during the fetch process
|
// Handle any errors thrown during the fetch process
|
||||||
const { response, ...rest } = error;
|
const { response, ...rest } = error;
|
||||||
reject({
|
reject({
|
||||||
|
|||||||
Reference in New Issue
Block a user