interface FetchOptions extends RequestInit { skipContentType?: boolean } export async function apiFetch(url: string, options: FetchOptions = {}): Promise { const headers: Record = { ...(options.headers as Record) } if (!options.skipContentType) { headers['Content-Type'] = 'application/json' } const response = await fetch(url, { ...options, headers, }) if (!response.ok) throw new Error(`API error: ${response.status}`) if (response.status === 204) return null as T return response.json() as Promise }