修复模型库空请求体删除失败
This commit is contained in:
@@ -6,10 +6,11 @@ function authHeaders(): Record<string, string> {
|
||||
}
|
||||
|
||||
export async function api<T>(url: string, options: RequestInit = {}): Promise<T> {
|
||||
const hasBody = options.body !== undefined && options.body !== null;
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
headers: {
|
||||
...(options.body instanceof FormData ? {} : { "Content-Type": "application/json" }),
|
||||
...(hasBody && !(options.body instanceof FormData) ? { "Content-Type": "application/json" } : {}),
|
||||
...authHeaders(),
|
||||
...((options.headers as Record<string, string> | undefined) ?? {})
|
||||
} as HeadersInit
|
||||
@@ -20,4 +21,3 @@ export async function api<T>(url: string, options: RequestInit = {}): Promise<T>
|
||||
}
|
||||
return data as T;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user