Files
ember-market-frontend/lib/data-service.ts
2025-02-07 21:33:13 +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;
}
}