Update page.tsx

This commit is contained in:
CanbiZ 2025-01-23 10:58:02 +01:00
parent ad2ea710a4
commit 9d46bd8f78

View File

@ -10,19 +10,20 @@ const CategoryView = () => {
const [selectedCategory, setSelectedCategory] = useState<Category | null>(null);
useEffect(() => {
const fetchCategories = async () => {
try {
const response = await fetch("/api/categories");
if (!response.ok) {
throw new Error("Failed to fetch categories");
}
const data = await response.json();
console.log("Fetched categories:", data); // Debugging
setCategories(data);
} catch (error) {
console.error("Error fetching categories:", error);
}
};
const fetchCategories = async () => {
try {
const basePath = process.env.NODE_ENV === "production" ? "/ProxmoxVE" : ""; // Passe den Basis-Pfad an
const response = await fetch(`${basePath}/api/categories`);
if (!response.ok) {
throw new Error("Failed to fetch categories");
}
const data = await response.json();
console.log("Fetched categories:", data); // Debugging
setCategories(data);
} catch (error) {
console.error("Error fetching categories:", error);
}
};
fetchCategories();
}, []);