ecommerce_sanity_stripe
ecommerce_sanity_stripe copied to clipboard
Error on Slug.js
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
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?
@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?
this is my product.jsx file sir
@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
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 ,
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 ,
this is my code above params. can you tell me what to change
Line 23 should say: https://codefile.io/f/O2jutdM2wO62ZiApBPcT
{
Line 23 should say: https://codefile.io/f/O2jutdM2wO62ZiApBPcT
 {
thankyou so much but after clearing that I got this error.kindly help me :(. Again Thanks in advance:)
That's great! The new error seems to be that slug should be all lowecase :)
slug: product.slug.current
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 } } }