fix teacher, parent and admin pages
This commit is contained in:
+11
-1
@@ -37,7 +37,17 @@ export async function apiFetch<T>(
|
||||
headers.set('Authorization', `Bearer ${token}`)
|
||||
}
|
||||
|
||||
const res = await fetch(apiUrl(path), { ...init, headers })
|
||||
const url = apiUrl(path)
|
||||
let res: Response
|
||||
try {
|
||||
res = await fetch(url, { ...init, headers })
|
||||
} catch (e) {
|
||||
const hint = import.meta.env.DEV
|
||||
? ' Start the API and ensure Vite can reach it (see vite.config.ts; default proxy is http://192.168.3.100:8000).'
|
||||
: ''
|
||||
const reason = e instanceof Error ? e.message : 'Failed to fetch'
|
||||
throw new ApiHttpError(`Network error: ${reason}.${hint}`, 0, null)
|
||||
}
|
||||
const body: unknown = await res.json().catch(() => null)
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user