In index.js i used getStaticProps function and export it. I wanted to whenever a user visit my page, my api call will run. But i wanted to make this api call every (for example) 60 seconds, not everytime for every user. But, revalidate its not working. I deployed it on vercel. But my website is making api call just ONCE and not doing again.
How can i fix that issue?
Here is my webstie: emirhash.vercel.app
I solved it. It's not about next.js, its about apollo's InMemoryCache class. I updated my apollo-client.js with following:
import { ApolloClient, InMemoryCache } from "@apollo/client";
const defaultOptions = {
watchQuery: {
// fetchPolicy: "cache-and-network",
fetchPolicy: "no-cache",
errorPolicy: "ignore",
},
query: {
// fetchPolicy: "network-only",
fetchPolicy: "no-cache",
errorPolicy: "all",
},
};
const client = new ApolloClient({
uri: "https://api-eu-central-1.graphcms.com/v2/cl21y31cg4c5u01z4fd5o11z6/master",
cache: new InMemoryCache(),
defaultOptions,
});
export default client;
And now everythings working as i expected. Thanks everyone.