From 3b915851f095425617d3fc0558d75d4cac8165a6 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Wed, 2 Aug 2023 15:02:16 +0200 Subject: [PATCH] Fixed a bug in the RequestUtil.js --- src/common/utils/RequestUtil.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/utils/RequestUtil.js b/src/common/utils/RequestUtil.js index 3d38510..c652516 100644 --- a/src/common/utils/RequestUtil.js +++ b/src/common/utils/RequestUtil.js @@ -11,11 +11,12 @@ export const request = async (url, method, body, headers) => { if (response.status === 401) throw new Error("Unauthorized"); - const data = await response.json(); + const rawData = await response.text(); + const data = rawData ? JSON.parse(rawData) : rawData.toString(); if (data.code >= 300) throw new Error(data.message); - if (!response.ok) throw new Error(await response.text()); + if (!response.ok) throw new Error(data.message); return data; }