Files
ember-market-frontend/lib/data-service.ts
NotII 39c349509c ugh
2025-03-24 01:46:11 +00:00

13 lines
393 B
TypeScript

/**
* Client-side fetch function for API requests.
*/
export async function fetchData(url: string, options: RequestInit = {}): Promise<any> {
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;
}
}