fix: restore native arm64 architecture support in Dockerfile and improve API error handling

This commit is contained in:
2026-08-10 07:32:02 +00:00
parent 6164e4ea9f
commit 859af13364
6 changed files with 574 additions and 313 deletions
+16 -2
View File
@@ -125,8 +125,22 @@ export function useHospitalStore() {
headers: { 'Content-Type': 'application/json' },
body: data ? JSON.stringify(data) : undefined,
});
if (!res.ok) throw new Error(`API error: ${res.statusText}`);
return await res.json().catch(() => ({ ok: true }));
if (!res.ok) {
let errText = res.statusText;
try {
const errData = await res.json();
if (errData && errData.error) errText = errData.error;
} catch {
// ignore json parse error
}
throw new Error(`API error: ${errText}`);
}
const text = await res.text();
try {
return JSON.parse(text);
} catch {
return { ok: true };
}
} catch (err) {
console.error(`API call failed: ${method} ${endpoint}`, err);
throw err;
+8 -4
View File
@@ -41,8 +41,10 @@ export function GestionUsuarios() {
const fetchUsuarios = async () => {
try {
const res = await fetch(`${API_BASE}/usuarios`);
const data = await res.json();
setUsuarios(data);
if (res.ok) {
const data = await res.json();
if (Array.isArray(data)) setUsuarios(data);
}
} catch (err) {
console.error(err);
} finally {
@@ -53,8 +55,10 @@ export function GestionUsuarios() {
const fetchGrupos = async () => {
try {
const res = await fetch(`${API_BASE}/grupos`);
const data = await res.json();
setGrupos(data);
if (res.ok) {
const data = await res.json();
if (Array.isArray(data)) setGrupos(data);
}
} catch (err) {
console.error(err);
}