From a893ed01f512c3df6904939c3503dd222645a438 Mon Sep 17 00:00:00 2001 From: "a.tolmachev" Date: Tue, 31 Mar 2026 01:04:10 +0300 Subject: [PATCH] fix: handle non-json api error responses --- apps/ui/js/api.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/ui/js/api.js b/apps/ui/js/api.js index b0d2160..66bb8ce 100644 --- a/apps/ui/js/api.js +++ b/apps/ui/js/api.js @@ -19,12 +19,12 @@ } var payload = null; - var text = ''; + var text = await response.text(); - try { - payload = await response.json(); - } catch (_error) { - text = await response.text(); + if (text) { + try { + payload = JSON.parse(text); + } catch (_error) {} } if (!response.ok) {