ecommerce_sanity_stripe icon indicating copy to clipboard operation
ecommerce_sanity_stripe copied to clipboard

Products not showing up error

Open Alba1020 opened this issue 2 years ago • 2 comments

image I am getting this message when first hooking up sanity, it is not pulling up the products I have created with sanity.

Alba1020 avatar Sep 09 '22 21:09 Alba1020

did you give it a prop

marvelous-007 avatar Jan 05 '23 16:01 marvelous-007

As @marvelous-007 have suggested, you might have forgotten to pass in the products prop in your getServerSideProps function.

// Get Server Side Props: https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props
export const getServerSideProps = async () => {
  // Sanity Query for Products
  const product_query = '*[_type == "product"]';
  const products = await client.fetch(product_query);

  // Sanity Query for Banner
  const banner_query = '*[_type == "banner"]';
  const banner = await client.fetch(banner_query);

  return {
    props: { products, banner },
  };
};

props: {products, banner} is where you want to check for this mistake.

Hope this helps :)

peanutsee avatar Aug 09 '23 04:08 peanutsee