client component SWR doesn’t update data
Unanswered
borghese posted this in #help-forum
borgheseOP
I’m having some issues with SWR and revalidating data.
Basically I have a client component that uses SWR to call an endpoint of the project’s api.
The route is pretty simple, get data from
Even with SWR set to revalidate after 30 seconds, I can see the request returning 304 - Not Modified even if the data (looking at the database) is actually completely different, does this has something to do with the way I’m querying the DB?
In case someone asks, the reason why I’m querying the DB inside the api is because I’m trying to get real time data on this client component and all of the data resides on the database, looks like nothing of what I found on the web is working and my inexperience with Next doesn’t help:(
Basically I have a client component that uses SWR to call an endpoint of the project’s api.
The route is pretty simple, get data from
mongodb client and returns it in a NextResponse.Even with SWR set to revalidate after 30 seconds, I can see the request returning 304 - Not Modified even if the data (looking at the database) is actually completely different, does this has something to do with the way I’m querying the DB?
In case someone asks, the reason why I’m querying the DB inside the api is because I’m trying to get real time data on this client component and all of the data resides on the database, looks like nothing of what I found on the web is working and my inexperience with Next doesn’t help:(