Anya
vjjhvk
export async function getStaticProps() {
const endpoint = process.env.NEXT_PUBLIC_GRAPHCMS_ENDPOINT;
if (!endpoint) {
console.error("GraphCMS endpoint is not defined");
return {
props: {
posts: [],
},
};
}
const client = new ApolloClient({
uri: endpoint,
cache: new InMemoryCache(),
});
try {
const { data } = await client.query({ query: getPosts });
// console.log("data", data);
return {
props: {
posts: data.postsConnection.edges ?? [],
},
};
} catch (error) {
console.error("Error in getStaticProps:", error.message);
return {
props: {
posts: [],
},
};
}
}
gcakusbcsjdbljsdbvl dfbvlnfbgf
aefbeifbusef
Full Stack Developer
No Categories Available
© 2024 Nextron Blog — Managed by Anjali |@anjalisah89
Contact for more information.