#Error: Cannot destructure property 'params' of 'undefined' as it is undefined.

14 messages · Page 1 of 1 (latest)

peak bloom
#

Hi guys !

I'm struggling with this code today. I'm trying to get a single product by its ID.

Example of URL is like that : http://localhost:3000/produit/1

So I used "params" to get the id "1".

But I got this error :

Error: Cannot destructure property 'params' of 'undefined' as it is undefined.

You can check a copy screen of my VSC.

Thanks for all guys !

lost turtle
#

pages in app dir no longer receives Request object. Its only for route.ts

peak bloom
#

oh I didn't know it !

#

so how do I get the ID ?

lost turtle
lost turtle
peak bloom
#

I'm trying

#

but your link is the same as I did

lost turtle
#

this is not valid syntax

#

id_prod is still a type

#

you need to destructure params or use params.id_prod

peak bloom
#

ok I just have to remove the first parameter