refactor(categories): change controller route from 'api/categories' to 'categories'
fix(products): update category fetch logic to ensure data is an array refactor(products): simplify GET handler by integrating authentication directly
This commit is contained in:
@@ -43,7 +43,9 @@ export default function EditProductForm({ product }: Props) {
|
||||
if (isOpen && categoryTree.length === 0) {
|
||||
fetch('/api/categories')
|
||||
.then((r) => r.json())
|
||||
.then((data: CategoryNode[]) => setCategoryTree(data))
|
||||
.then((data: unknown) => {
|
||||
if (Array.isArray(data)) setCategoryTree(data as CategoryNode[]);
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
Reference in New Issue
Block a user