From 4dfc990c3293ae57c9541aebbb7fed1fd77e0662 Mon Sep 17 00:00:00 2001 From: Roland Bernard <rolbernard@unibz.it> Date: Thu, 20 May 2021 23:27:38 +0200 Subject: [PATCH] Fixed the image upload adapter --- client/src/adapters/util.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client/src/adapters/util.ts b/client/src/adapters/util.ts index dcaa7e1..dfa7402 100644 --- a/client/src/adapters/util.ts +++ b/client/src/adapters/util.ts @@ -22,13 +22,15 @@ async function executeApiRequest<T>(path: string, method: string, body: any, onS method: method, headers: { ...getAuthHeader(), - ...(body ? ( - body instanceof FormData - ? { 'Content-Type': 'multipart/form-data' } - : { 'Content-Type': 'application/json' }) + ...(body && !(body instanceof FormData) + ? { 'Content-Type': 'application/json' } : { }), }, - body: body ? JSON.stringify(body) : undefined, + body: body + ? (body instanceof FormData + ? body + : JSON.stringify(body)) + : undefined, }); if (response.ok) { return onSuccess(await response.json()); -- GitLab