diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2025-11-26 14:56:36 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2025-11-26 14:56:36 +0700 |
| commit | adc316e70faf20ea375b3e590998a36997b6b6e2 (patch) | |
| tree | 8a98f7cdebda18046dc10858a14d1d2e49759bd1 /src/api | |
| parent | c472261f34388a0b76c3e21fec494b8d5f304715 (diff) | |
<Miqdad> balikin
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/productApi.js | 21 |
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; -} |
