Revalidate Path not working as expected
Unanswered
Tan posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
TanOP
I am working on a addToCart functionality of a pizza ordering application, in the handle-click function (which is on a client component) i call the server function with required params, and in the server function I implement logic to add item to cart and revalidatePath('cart') and redirect('cart'), but the cart page behaves differently. It shows the pizza in cart when I add it for first time but then it doesn't on subsequent addToCart calls, i have to manually reload to see the item in cart. What could I be doing wrong ? (I am new to nextJs!)
![Image](https://cdn.discordapp.com/attachments/1174969222137397279/1174969222686834698/Screenshot_2023-11-17_at_12.35.12_PM.png?ex=6569865c&is=6557115c&hm=e0c657740aa2d5589adf8a00b121bd86cce5b96918d2dbfba5e084963f1f4c3b&)
![Image](https://cdn.discordapp.com/attachments/1174969222137397279/1174969223261458452/Screenshot_2023-11-17_at_12.35.53_PM.png?ex=6569865c&is=6557115c&hm=0b14eb4ceaf15163674e6dfe224636c05c306dce92f97480cbdb1e5124ef13db&)
4 Replies
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
Didnt read the code but firstly, revalidate functions work on subsequent requests and secondly you shouldn't need to revalidate when you are using "react state" and its all on the same page
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
TanOP
It's not on the same page I have a pizza page which includes a pizzaOptions component (client component) which is responsible for making a call to handleClick function which in turn calls the addToCart server function which should create order and orderItems in my DB and redirect to the cart page where they will be rendered
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
TanOP
deployed link - https://doughlicious.vercel.app
code link - https://github.com/AyushShende/doughlicious