Skip to content

Commit

Permalink
Update page.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
MickLesk committed Jan 23, 2025
1 parent a025fd9 commit 9f3a1c8
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions frontend/src/app/category-view/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}, []);
Expand Down

0 comments on commit 9f3a1c8

Please sign in to comment.