From fcec4f3db4c925d3140d05636e4a668da6965671 Mon Sep 17 00:00:00 2001 From: zhangshun <453905631@qq.com> Date: Mon, 1 Jun 2026 09:50:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A8=A1=E5=9E=8B=E5=BA=93?= =?UTF-8?q?=E7=A9=BA=E8=AF=B7=E6=B1=82=E4=BD=93=E5=88=A0=E9=99=A4=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/services/api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/services/api.ts b/web/src/services/api.ts index da200b3..359b009 100644 --- a/web/src/services/api.ts +++ b/web/src/services/api.ts @@ -6,10 +6,11 @@ function authHeaders(): Record { } export async function api(url: string, options: RequestInit = {}): Promise { + 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 | undefined) ?? {}) } as HeadersInit @@ -20,4 +21,3 @@ export async function api(url: string, options: RequestInit = {}): Promise } return data as T; } -