(url: string)
| 1 | export const fetchApiData = async <T>(url: string): Promise<T> => { |
| 2 | const response = await fetch(url); |
| 3 | |
| 4 | if (!response.ok) { |
| 5 | throw new Response(`Failed to fetch data from ${url}`, { |
| 6 | status: response.status, |
| 7 | statusText: response.statusText, |
| 8 | }); |
| 9 | } |
| 10 | |
| 11 | return response.json() as T; |
| 12 | }; |