diff --git a/frontend/src/composables/useApi.js b/frontend/src/composables/useApi.js index 06e3cba..ba10bb5 100644 --- a/frontend/src/composables/useApi.js +++ b/frontend/src/composables/useApi.js @@ -24,7 +24,16 @@ async function request(path, opts = {}) { async function requestJSON(path, opts = {}) { const res = await request(path, opts) - if (!res.ok) throw res + if (!res.ok) { + let msg = `${res.status}` + try { + const body = await res.json() + msg = body.detail || body.message || msg + } catch {} + const err = new Error(msg) + err.status = res.status + throw err + } return res.json() }