path correction

This commit is contained in:
sandhiya-hepl
2026-07-15 18:22:52 +05:30
parent e84c1adac4
commit abb35c0e03
15 changed files with 518 additions and 42 deletions
+9 -1
View File
@@ -22,7 +22,15 @@ async function apiFetch(path, options = {}) {
const res = await fetch(`${API_BASE}${path}`, { ...options, headers });
const data = await res.json().catch(() => ({}));
if (!res.ok) throw new Error(data.error || 'Request failed');
if (!res.ok) {
const fallback =
res.status === 404
? 'API not found. Deploy server/ and run: npm run server (port 3001)'
: res.status === 502
? 'API server unreachable. Start Node on the host (port 3001).'
: 'Request failed';
throw new Error(data.error || fallback);
}
return data;
}