Next.js getStaticProps error in production. GraphQL Apollo client not rendering variable, instead getting error: Type error: No value exists in scope

Next.js getStaticProps error in production. GraphQL Apollo client not rendering variable, instead getting error: Type error: No value exists in scope


0

My code seems to work in development but when I step away from the local environment, i get an error: Type error: No value exists in scope for the shorthand property 'currentTime'. Either declare one or provide an initializer.

Next.js getStaticProps error in production. GraphQL Apollo client not rendering variable, instead getting error: Type error: No value exists in scope

I am using Next.js and Typescript. I am not sure if this is a type error.

I can’t find an answer anywhere online

I am mainly just trying to include a "where" option to my query where it uses the "Current Time" to query only the data "lte" or "gte".

I don’t know how to query for current date and time so I created a variable called "currentTime" in the scope of the getStaticProps function, and it works locally.

export const getStaticProps: GetStaticProps = async ({ params }) => {
  const currentTime = await new Date().toISOString();
  const results = await client.query({
    query: GET_PAST_EVENTS,
    variables: { currentTime },
  });
  if (!results) {
    return { notFound: true };
  }
  console.log(results);
  return {
    props: {
      data: results.data,
    },
    revalidate: 600,
  };
};

I have tried to use getStaticPaths but this is not a dynamic page.


Load 5 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *