1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-02-01 14:51:50 +00:00

Update page.tsx

This commit is contained in:
CanbiZ 2025-01-23 11:29:03 +01:00
parent a025fd948e
commit 9f3a1c8531

View File

@ -12,19 +12,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" : "";
const response = await fetch(`${basePath}/json/categories.json`);
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();
}, []);