Next.js Discord

Discord Forum

Nextjs revalidate not working

Unanswered
Saltwater Crocodile posted this in #help-forum
Open in Discord
Saltwater CrocodileOP
I am trying to update a next ssg app from wordpress cms, however, after deploying on aws, and i refresh the website, it fetches the updated data , when refresh again, it displays the old data, after some minutes, it only displays the old data. I have watched videos on static rendering and data caching, i do not know why this is not working. I expect that after 2 secs it should revalidate and cache the cureent data

Here is my function below

export async function fetchAPI(query = "", { variables } = {}) { const res = await fetch(process.env.NEXT_PUBLIC_WORDPRESS_API_ENDPOINT, { method: "post", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ query, variables, }), next: { revalidate: 2 }, }); if (!res.ok) { console.error(res); return {}; } const { data } = await res.json(); return data; }

2 Replies

Western yellowjacket
i have the same problem
Saltwater CrocodileOP
Have you been able to fix it?