import {getConfigValue} from "@brojs/cli"; const LOCAL = "http://localhost:8099"; const DEV = "https://dev.bro-js.ru"; const SERVER = ""; export const BASE_API_URL = DEV + getConfigValue("enterfront.api"); // fetch(`${BASE_API_URL}/books/list`) export async function post(path, body) { const res = await fetch(`${BASE_API_URL}${path}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(body) }); 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); return {ok: false, data: errorData}; } } export async function get(path){ const res = await fetch(`${BASE_API_URL}${path}`, { method: "GET" }); if (res.status === 200) { const data = await res.json(); console.log("Received get:", data); return {ok: true, data: data}; } else { const errorData = await res.json(); console.log("Error during get:", errorData.message); return {ok: false, data: errorData}; } }