feat: call one time getCartToken

This commit is contained in:
DuvCharles 2023-03-24 17:20:52 +01:00 committed by Hadrien Lucas
parent 9bc876e02e
commit 4b357bdf2f
2 changed files with 4 additions and 3 deletions

View File

@ -36,7 +36,7 @@ NEXT_PUBLIC_SYLIUS_API_URL=127.0.1:8000
NEXT_PUBLIC_SYLIUS_ALLOWED_IMAGE_DOMAIN=127.0.0.1
```
4. With the Sylius server running, start this project using `yarn dev` or `npm run dev`.
4. With the Sylius server running, start this project using `yarn dev`.
### Known Limitations

View File

@ -13,9 +13,10 @@ export const handler: SWRHook<GetCartHook> = {
method: 'GET',
},
fetcher: async ({ options, fetch }) => {
if (getCartToken()) {
const cartToken = getCartToken()
if (cartToken) {
const syliusCart = await fetch({
url: `${options.url}/${getCartToken()}`,
url: `${options.url}/${cartToken}`,
method: options.method,
})
return normalizeCart(syliusCart)