Workforce locations: include Tanda error body in 502 response
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
db1b168300
commit
5a9a05bb62
1 changed files with 5 additions and 1 deletions
|
|
@ -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 })))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue