fix:delete ticket ui
This commit is contained in:
@@ -16,10 +16,14 @@ export class ApiError extends Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function apiFetch<T>(path: string, init: RequestInit = {}): Promise<T> {
|
async function apiFetch<T>(path: string, init: RequestInit = {}): Promise<T> {
|
||||||
|
const hasBody = init.body != null;
|
||||||
const res = await fetch(`${API}${path}`, {
|
const res = await fetch(`${API}${path}`, {
|
||||||
...init,
|
...init,
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: { "Content-Type": "application/json", ...(init.headers ?? {}) },
|
headers: {
|
||||||
|
...(hasBody ? { "Content-Type": "application/json" } : {}),
|
||||||
|
...(init.headers ?? {}),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
// Try to parse a structured error body; fall back to a generic message
|
// Try to parse a structured error body; fall back to a generic message
|
||||||
@@ -34,6 +38,9 @@ async function apiFetch<T>(path: string, init: RequestInit = {}): Promise<T> {
|
|||||||
}
|
}
|
||||||
throw new ApiError(res.status, code, message);
|
throw new ApiError(res.status, code, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
if (res.status === 204) return undefined as T;
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6966
package-lock.json
generated
Normal file
6966
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user