KI-AGENT: Leere JSON Requests in der Mobile App korrigieren
This commit is contained in:
@@ -313,14 +313,15 @@ async function parseJson(response: Response): Promise<unknown> {
|
||||
}
|
||||
|
||||
export async function apiRequest<T>(path: string, options: RequestOptions = {}): Promise<T> {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user