export function getJsonOrError(response: Response) { if (!response.ok) { return response.json().then((data) => { throw new Error(data.error || 'Request failed') }) } return response.json() }