summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/index.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/pages/index.js b/src/pages/index.js
index b233f81e..94be7f3a 100644
--- a/src/pages/index.js
+++ b/src/pages/index.js
@@ -42,11 +42,18 @@ export default function Home({ heroBanners }) {
getPopularProducts();
const getCategoryProducts = async () => {
- const dataCategoryProducts = await apiOdoo('GET', '/api/v1/categories_homepage');
- setCategoryProducts(dataCategoryProducts);
+ if (!categoryProducts) {
+ const categoryIds = await apiOdoo('GET', '/api/v1/categories_homepage/ids');
+ const categories = [];
+ for (const id in categoryIds) {
+ const dataCategoryProducts = await apiOdoo('GET', `/api/v1/categories_homepage?id=${id}`);
+ categories.push(...dataCategoryProducts);
+ setCategoryProducts(categories);
+ }
+ }
}
getCategoryProducts();
- }, []);
+ }, [ categoryProducts ]);
return (
<>