diff --git a/src/routes/integrations.js b/src/routes/integrations.js index 6f214cb..fc3cea1 100644 --- a/src/routes/integrations.js +++ b/src/routes/integrations.js @@ -127,7 +127,11 @@ export async function integrationRoutes(app) { headers: { Authorization: `Bearer ${creds.bearer_token}` }, signal: AbortSignal.timeout(8000), }) - if (!res.ok) return reply.status(502).send({ error: `Workforce API error (${res.status})` }) + if (!res.ok) { + const body = await res.text().catch(() => '') + const msg = (() => { try { return JSON.parse(body).error } catch { return body.slice(0, 200) } })() + return reply.status(502).send({ error: msg || `Workforce API error (${res.status})` }) + } const data = await res.json() const items = Array.isArray(data) ? data : (data.locations ?? []) locations.push(...items.map(l => ({ id: String(l.id), name: l.name, short_name: l.short_name ?? null })))