export async function fetchJson(url, options = {}) { const response = await fetch(url, options); const text = await response.text(); const data = text ? JSON.parse(text) : null; if (!response.ok) { throw new Error(data?.error || `HTTP ${response.status}`); } return data; }