summaryrefslogtreecommitdiff
path: root/src/api/productApi.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/productApi.js')
-rw-r--r--src/api/productApi.js21
1 files changed, 2 insertions, 19 deletions
diff --git a/src/api/productApi.js b/src/api/productApi.js
index b5f47bcf..dc96a77e 100644
--- a/src/api/productApi.js
+++ b/src/api/productApi.js
@@ -1,6 +1,5 @@
import axios from 'axios';
-// CLIENT MODE → untuk useQuery
export const popularProductApi = () => {
return async () => {
const today = new Date();
@@ -8,25 +7,9 @@ export const popularProductApi = () => {
(today - new Date(today.getFullYear(), 0, 0)) / 86400000
);
const page = (dayOfYear % 24) + 1;
-
- const res = await axios(
+ const dataPopularProducts = await axios(
`${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/search?q=*&page=${page}&orderBy=stock&priceFrom=1`
);
- return res.data.response;
+ return dataPopularProducts.data.response;
};
};
-
-// SERVER MODE → untuk SSR
-export async function popularProductApiSSR() {
- const today = new Date();
- const dayOfYear = Math.floor(
- (today - new Date(today.getFullYear(), 0, 0)) / 86400000
- );
- const page = (dayOfYear % 24) + 1;
-
- const res = await axios(
- `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/search?q=*&page=${page}&orderBy=stock&priceFrom=1`
- );
-
- return res.data.response || null;
-}