diff --git a/frontend/index.html b/frontend/index.html index 4e92dbc..42b9df0 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ - + Vite + React diff --git a/frontend/src/services/api.js b/frontend/src/services/api.js index 5f86fe2..63eb6cf 100644 --- a/frontend/src/services/api.js +++ b/frontend/src/services/api.js @@ -1,7 +1,10 @@ -const API_BASE = import.meta.env.VITE_API_BASE; +const API_BASE = window?.ENV?.API_BASE || ""; export async function fetchDiagram() { const res = await fetch(`${API_BASE}/diagram/fetch`); + if (!res.ok) { + throw new Error(`Failed to fetch diagram: ${res.status}`); + } return await res.json(); } @@ -11,11 +14,18 @@ export async function saveDiagram(data) { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data), }); + + if (!res.ok) { + throw new Error(`Failed to save diagram: ${res.status}`); + } + return await res.json(); } export async function fetchIconCategories() { const res = await fetch(`${API_BASE}/icons`); + if (!res.ok) { + throw new Error(`Failed to fetch icons: ${res.status}`); + } return await res.json(); } -