From cd65fd35be13df837347f58e65f8535c00fdcb78 Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Mon, 6 Apr 2026 21:28:18 +0000 Subject: [PATCH] Fix login: parse API error body into Error.message api.post/get/put/delete now throw Error with .message from response body (detail/message field), not raw Response object. Fixes login modal showing no feedback on auth failure. Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/composables/useApi.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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() }