Fix 400 on NewBook sync and run-due: send empty JSON body

Fastify rejects POST requests that carry Content-Type: application/json
but an empty body (JSON.parse('') throws). Both no-body POSTs now send {}.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-08 11:10:14 +00:00
parent 3289a31027
commit 2a3a226131

View file

@ -29,7 +29,7 @@ export function updateLocation(id: number, body: Partial<Location>): Promise<Loc
return request(`/locations/${id}`, { method: 'PATCH', body: JSON.stringify(body) }) return request(`/locations/${id}`, { method: 'PATCH', body: JSON.stringify(body) })
} }
export function syncNewbookRooms(): Promise<{ ok: boolean; created: number; updated: number; total: number }> { export function syncNewbookRooms(): Promise<{ ok: boolean; created: number; updated: number; total: number }> {
return request('/locations/sync-newbook', { method: 'POST' }) return request('/locations/sync-newbook', { method: 'POST', body: JSON.stringify({}) })
} }
export function createCategory(body: { name: string; sort_order?: number; is_rooms?: boolean }): Promise<Category> { export function createCategory(body: { name: string; sort_order?: number; is_rooms?: boolean }): Promise<Category> {
return request('/categories', { method: 'POST', body: JSON.stringify(body) }) return request('/categories', { method: 'POST', body: JSON.stringify(body) })
@ -193,7 +193,7 @@ export function updateTemplate(id: number, body: Record<string, unknown>): Promi
return request(`/templates/${id}`, { method: 'PATCH', body: JSON.stringify(body) }) return request(`/templates/${id}`, { method: 'PATCH', body: JSON.stringify(body) })
} }
export function runDueTemplates(): Promise<{ ok: boolean; spawned: number }> { export function runDueTemplates(): Promise<{ ok: boolean; spawned: number }> {
return request('/templates/run-due', { method: 'POST' }) return request('/templates/run-due', { method: 'POST', body: JSON.stringify({}) })
} }
// Config // Config