Data is cached when I make a POST adding a new item
Unanswered
Asiatic Lion posted this in #help-forum
Asiatic LionOP
I've been dealing with this since 2 days ago, before it was working fine.
First I create a brand using the addBrand function under a "use client" page. As you can see in the first image. When the response is ok, it calls fetchCategories() function which is the function that gets me all the brands (this should bring the new added brand and its not bringing it).
This fetchCategories function lives in a zustand store as you can see on the second image.
And the store calls the api route tha is on the third image. I tried using export const revalidate=0; but its not working.
First I create a brand using the addBrand function under a "use client" page. As you can see in the first image. When the response is ok, it calls fetchCategories() function which is the function that gets me all the brands (this should bring the new added brand and its not bringing it).
This fetchCategories function lives in a zustand store as you can see on the second image.
And the store calls the api route tha is on the third image. I tried using export const revalidate=0; but its not working.
5 Replies
@Asiatic Lion I've been dealing with this since 2 days ago, before it was working fine.
First I create a brand using the addBrand function under a "use client" page. As you can see in the first image. When the response is ok, it calls fetchCategories() function which is the function that gets me all the brands (this should bring the new added brand and its not bringing it).
This fetchCategories function lives in a zustand store as you can see on the second image.
And the store calls the api route tha is on the third image. I tried using export const revalidate=0; but its not working.
Have you tried adding "{ cache: 'no-store' }" at the end of your GET request in image 2 similar to the attached image? Here is the documentation: https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#individual-fetch-requests
@Asiatic Lion I've been dealing with this since 2 days ago, before it was working fine.
First I create a brand using the addBrand function under a "use client" page. As you can see in the first image. When the response is ok, it calls fetchCategories() function which is the function that gets me all the brands (this should bring the new added brand and its not bringing it).
This fetchCategories function lives in a zustand store as you can see on the second image.
And the store calls the api route tha is on the third image. I tried using export const revalidate=0; but its not working.
Also one way to check if it's a caching error is to manually revalidate the cache using CTRL + SHIFT + R
@Robinhood Have you tried adding "{ cache: 'no-store' }" at the end of your GET request in image 2 similar to the attached image? Here is the documentation: https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#individual-fetch-requests
Asiatic LionOP
Yes i did try it, and didn't work 😦
Asiatic LionOP
I just tried it and it did work. Meaning i got the new data