Files
next-coins/app/lib/fetch.ts
2026-03-04 02:35:48 +01:00

8 lines
237 B
TypeScript

export const fetchApi = async <T = any>(url: string): Promise<T> => {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
};