ecommerce_sanity_stripe icon indicating copy to clipboard operation
ecommerce_sanity_stripe copied to clipboard

Error on Slug.js

Open pradapdp7 opened this issue 2 years ago • 9 comments

Screenshot (83)

Hi, I'm getting this issue after running slug.js. I'm currently at 1:28:00min in the video. Kindly Help me to fix this error

pradapdp7 avatar May 14 '22 06:05 pradapdp7

@pradapdp7

The error you are getting appears to be stemming from the Product.jsx file within the components folder, not the [slug].js file. What does your Product.jsx look like?

miahthegreat avatar May 14 '22 20:05 miahthegreat

@pradapdp7

The error you are getting appears to be stemming from the Product.jsx file within the components folder, not the [slug].js file. What does your Product.jsx look like? Screenshot (84) this is my product.jsx file sir

pradapdp7 avatar May 22 '22 13:05 pradapdp7

@pradapdp7

The error you are getting appears to be stemming from the Product.jsx file within the components folder, not the [slug].js file. What does your Product.jsx look like?

here, the home page works fine but when i click any product this error pops up

pradapdp7 avatar May 22 '22 16:05 pradapdp7

No, the error is on slug page. I can't see above params: on the first screenshot, but it says you're missing a , Make sure the line above params on [slug].js ends with a comma ,

sodapopjam avatar May 25 '22 06:05 sodapopjam

No, the error is on slug page. I can't see above params: on the first screenshot, but it says you're missing a , Make sure the line above params on [slug].js ends with a comma , Screenshot (89)

this is my code above params. can you tell me what to change

pradapdp7 avatar May 25 '22 10:05 pradapdp7

Line 23 should say: https://codefile.io/f/O2jutdM2wO62ZiApBPcT

170246595-b1e13a57-a2d7-49da-8b45-878a3d205405 {

sodapopjam avatar May 25 '22 12:05 sodapopjam

Line 23 should say: https://codefile.io/f/O2jutdM2wO62ZiApBPcT

![170246595-b1e13a57-a2d7-49da-8b45-878a3d205405](https://user-images.githubusercontent.com/69822895/170260368-c2ec91ae-5935-451c-8c50-09 Screenshot (90) cf9f8dcdfc.png) {

thankyou so much but after clearing that I got this error.kindly help me :(. Again Thanks in advance:)

pradapdp7 avatar May 25 '22 16:05 pradapdp7

That's great! The new error seems to be that slug should be all lowecase :)

slug: product.slug.current

sodapopjam avatar May 25 '22 18:05 sodapopjam

I am stuck on TypeError: Cannot destructure property 'image' of 'product' as it is null. clicking on the button /// when clicking on the product it works ... my brain got scrambled pls help, pretty please.

export const getStaticPaths = async () => { const query = *[_type == "product"] { slug { current } } const products = await client.fetch(query); const paths = products.map((product) => ({ params: { slug: product.slug.current } }));

return { paths, fallback: 'blocking' } }

export const getStaticProps = async ({ params: { slug }}) => { const query = *[_type == "product" && slug.current == '${slug}'][0]; const product = await client.fetch(query);

const productsQuery = '*[_type == "product"]' const products = await client.fetch(productsQuery);

return { props: { products, product } } }

vaniadimova avatar Jun 24 '22 19:06 vaniadimova