8 lines
237 B
TypeScript
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();
|
|
};
|