Sanity Nextjs ReferenceError: clientConfigured is not defined

14 views Asked by At

I am configuring Sanity in my nextjs project, I am fetching the sanity data from the beginning of my app, in the _app.js file

I am doing it using the getServerSideProps() function

everything prints correctly in the console, the only detail is that an error in the interface does not let me advance where it says that

let clientConfigured = false;

ReferenceError: clientConfigured is not defined

but when printing it in the console it is defined and even its status changes.

let clientConfigured = false;
async function getServerSideProps() {
  if (!clientConfigured) {
    clientConfigured = true;
    const { POSTS_QUERY } = await import("../sanity/lib/queries");
    const { loadQuery } = await import("../sanity/lib/store");
    const initial = await loadQuery(POSTS_QUERY);
    return {
      props: {
        posts: initial.data,
      },
    };
  }
}

getServerSideProps();

and here the error:

enter image description here

Can someone help me? thank you

I tried to put the variable declaration inside the function but it doesn't work either, same error

0

There are 0 answers