Article on

Nextjs

Featured Image
Published: Jun 10, 2024

Nextjs

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: [],
      },
    };
  }
}
Onepiece.jpg

gcakusbcsjdbljsdbvl dfbvlnfbgf

aefbeifbusef

Anya

Anya

Full Stack Developer

Comment Your Thoughts

Comments

No comments yet.

Recent Posts

No Posts Available

Trending Topics

No Categories Available

Never miss a beat!
Subscribe for the latest articles, reviews and tech insights straight to your inbox.

© 2024 Nextron Blog — Managed by Anjali |@anjalisah89

Contact for more information.