Next.js Discord

Discord Forum

Get params from uri

Answered
Scarlet Ibis posted this in #help-forum
Open in Discord
Scarlet IbisOP
So I have this for example:
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?
Answered by Yi Lon Ma
- {params:{id:string}}
+ {params:Promise<{id:string}>}
View full answer

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!