0

In a NEWXTJS project, I'm using the SWR library to fetch an array of objects from a MongoDB database. The objects in the array are rendered in a table that is editable, meaning the user can modify a cell, and then its value is updated in the MongoDB database. To reflect the changes, I'm using the mutate() function from the SWR library, which, if there are any changes in the data, uses the data returned by the endpoint to update the table view.

Everything works as expected when the project is tested in the local development environment. However, when it is built with "npm run build" and then tested in a production environment with "npm run start" or deployed on Vercel, the issue arises that when the user makes changes in the table, they are not reflected in the view. In other words, the table is not rendered with the new data. I have confirmed that in the production environment, the changes in the frontend table are successfully saved in the MongoDB database. The problem seems to be that the mutate() function is still fetching the data from the cache instead of the endpoint.

What could be the problem?

0 Answers0