KI-AGENT: Leere JSON Requests in der Mobile App korrigieren

This commit is contained in:
2026-05-22 18:18:09 +02:00
parent d6582dd767
commit ab4055f2a5

View File

@@ -313,14 +313,15 @@ async function parseJson(response: Response): Promise<unknown> {
} }
export async function apiRequest<T>(path: string, options: RequestOptions = {}): Promise<T> { export async function apiRequest<T>(path: string, options: RequestOptions = {}): Promise<T> {
const hasJsonBody = options.body !== undefined;
const response = await fetch(buildUrl(path), { const response = await fetch(buildUrl(path), {
method: options.method || 'GET', method: options.method || 'GET',
headers: { headers: {
Accept: 'application/json', Accept: 'application/json',
'Content-Type': 'application/json', ...(hasJsonBody ? { 'Content-Type': 'application/json' } : {}),
...(options.token ? { Authorization: `Bearer ${options.token}` } : {}), ...(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); const payload = await parseJson(response);