Error fetching data using nextjs typescript

Hello i am trying to fetch data using the example in the docs for typescript but i keep getting an error

this is the code

export async function getStaticProps({ previewData }: GetStaticPropsContext) {
  const client = createClient({ previewData });
  //    ^ Automatically contains references to document types

  const page = await client.getSingle('home');
  //    ^ Typed as PageDocument
  console.log(page.data);

  return {
    props: {
      page,
    },
  };
}

This is the Error i get:

Server Error

Error: No documents were returned

Please can anyone help

I have been able to fix it... for some reason i skipped the publish button

1 Like