Answer the question
In order to leave comments, you need to log in
How to update NEXTJS post data after page reload?
Page [id].jsx
export async function getStaticProps({ params }) {
const res = await fetch(`api`);
const data = await res.json();
return {
props: {
post: data
},
revalidate: 1,
}
}
export async function getStaticPaths() {
const res = await fetch('api');
const allpost = await res.json();
return {
paths: allpost?.data.map(({ id }) => `/stocks/${id}`),
fallback: 'blocking'
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question