From 59cc17791318e4499ab04d2c88312df465687ef2 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 17 Feb 2025 17:23:26 +0700 Subject: [PATCH] handle expected empty response --- frontend/src/functions/APIClient.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/functions/APIClient.ts b/frontend/src/functions/APIClient.ts index 48b7900a..c01ba8b8 100644 --- a/frontend/src/functions/APIClient.ts +++ b/frontend/src/functions/APIClient.ts @@ -55,8 +55,15 @@ const APIClient = async ( throw new Error('Forbidden: Access denied.'); } - // Try parsing response data let data; + + // expected empty response + if (response.status === 204) { + data = null; + return data; + } + + // Try parsing response data try { data = await response.json(); } catch (error) {