From ab4055f2a5fa8a25eca64b0818caef954c230990 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Fri, 22 May 2026 18:18:09 +0200 Subject: [PATCH] KI-AGENT: Leere JSON Requests in der Mobile App korrigieren --- mobile/src/lib/api.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mobile/src/lib/api.ts b/mobile/src/lib/api.ts index 2a579db..1742f48 100644 --- a/mobile/src/lib/api.ts +++ b/mobile/src/lib/api.ts @@ -313,14 +313,15 @@ async function parseJson(response: Response): Promise { } export async function apiRequest(path: string, options: RequestOptions = {}): Promise { + const hasJsonBody = options.body !== undefined; const response = await fetch(buildUrl(path), { method: options.method || 'GET', headers: { Accept: 'application/json', - 'Content-Type': 'application/json', + ...(hasJsonBody ? { 'Content-Type': 'application/json' } : {}), ...(options.token ? { Authorization: `Bearer ${options.token}` } : {}), }, - body: options.body ? JSON.stringify(options.body) : undefined, + body: hasJsonBody ? JSON.stringify(options.body) : undefined, }); const payload = await parseJson(response);