Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on Slug.js #20

Open
pradapdp7 opened this issue May 14, 2022 · 9 comments
Open

Error on Slug.js #20

pradapdp7 opened this issue May 14, 2022 · 9 comments

Comments

@pradapdp7
Copy link

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

@miahthegreat
Copy link

miahthegreat commented May 14, 2022

@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
Copy link
Author

@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
Copy link
Author

@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

@sodapopjam
Copy link

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 ,

@pradapdp7
Copy link
Author

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

@sodapopjam
Copy link

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

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

@pradapdp7
Copy link
Author

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:)

@sodapopjam
Copy link

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

slug: product.slug.current

@vaniadimova
Copy link

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 }
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants