/** * Client-side fetch function for API requests. */ export async function fetchData(url: string, options: RequestInit = {}): Promise { try { const res = await fetch(url, options); if (!res.ok) throw new Error(`Request failed: ${res.statusText}`); return res.json(); } catch (error) { console.error(`Fetch error at ${url}:`, error); throw error; } }