From d1091e570bd3ec6ab1bcf9018ba078e6a4638242 Mon Sep 17 00:00:00 2001 From: Nikolai Petukhov Date: Thu, 3 Oct 2024 23:01:38 +0300 Subject: [PATCH] check json format --- src/backend/api.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/backend/api.js b/src/backend/api.js index d9d5199..a28405a 100644 --- a/src/backend/api.js +++ b/src/backend/api.js @@ -5,7 +5,7 @@ const LOCAL = "http://localhost:8099"; const DEV = "https://dev.bro-js.ru"; const SERVER = ""; -export const BASE_API_URL = DEV + getConfigValue("enterfront.api"); +export const BASE_API_URL = LOCAL + getConfigValue("enterfront.api"); // fetch(`${BASE_API_URL}/books/list`) @@ -21,18 +21,18 @@ export async function post(path, body) { body: JSON.stringify(body) }); - console.log('Data from API:', res); + const data = JSON.parse(await res.text()); + + console.log("Data from API:", data) if (res.status === 200) { - const data = await res.json(); console.log("Received post:", data); return {ok: true, data: data}; } else { - const errorData = await res.json(); - console.log("Error during post:", errorData.message); + console.log("Error during post:", data.message); - return {ok: false, data: errorData}; + return {ok: false, data: data}; } }