2025-03-03 10:10:57 +01:00

11 lines
313 B
TypeScript

import { Category } from "./types";
export const fetchCategories = async () => {
const response = await fetch("api/categories");
if (!response.ok) {
throw new Error(`Failed to fetch categories: ${response.statusText}`);
}
const categories: Category[] = await response.json();
return categories;
};