forked from imranhsayed/nextjs-woocommerce-restapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.js
31 lines (26 loc) · 943 Bytes
/
cart.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import Layout from '../src/components/layout';
import { HEADER_FOOTER_ENDPOINT } from '../src/utils/constants/endpoints';
import axios from 'axios';
import CartItemsContainer from '../src/components/cart/cart-items-container';
export default function Cart({ headerFooter }) {
return (
<Layout headerFooter={headerFooter || {}}>
<h1 className="uppercase tracking-0.5px">Cart</h1>
<CartItemsContainer/>
</Layout>
);
}
export async function getStaticProps() {
const { data: headerFooterData } = await axios.get( HEADER_FOOTER_ENDPOINT );
return {
props: {
headerFooter: headerFooterData?.data ?? {},
},
/**
* Revalidate means that if a new request comes to server, then every 1 sec it will check
* if the data is changed, if it is changed then it will update the
* static file inside .next folder with the new data, so that any 'SUBSEQUENT' requests should have updated data.
*/
revalidate: 1,
};
}