Get params from uri
Answered
Scarlet Ibis posted this in #help-forum
Scarlet IbisOP
So I have this for example:
But the second line says:
But NextJS tell us to do await. So what to do?
const Post = async ({ params }: { params: { id: string } }) => {
const { id } = await params;
const post = await getPost(id)
But the second line says:
'await' has no effect on the type of this expression.ts(80007)
But NextJS tell us to do await. So what to do?
3 Replies
this is because of your incorrect typescript types
- {params:{id:string}}
+ {params:Promise<{id:string}>}
Answer
@Yi Lon Ma this is because of your incorrect typescript types
Scarlet IbisOP
Thank you!