#Dyanamic routes problem in next 15

17 messages · Page 1 of 1 (latest)

eager swift
#

// app/profile/[id]/page.tsx

export default async function Page({params}:{
params:Promise<{id:string}>
}) {

const id = (await params).id;

return (
<div>
<h1>Profile Page</h1>
<p>User ID: {id}</p>
</div>
);
}
I am creating a chat application
And the user collection is Stored in mongodb
But here in the route it is not coming sd the user id it is showing undefined
#1019763807465246801

modern creek
#

what is params?

#

does params return a promise?

eager swift
#

Yes I did it with promise

#

I resolved this error just now

#

In left side bar where i am doing if rout.link==profile in that iff condition i added &&user id also
By that it will check the route as well as the user id so by this change it was working

#

Without user id it was showing undefined

modern creek
#

also add a if block to check whether params was undefined

modern creek
#

avoid (await params).id

eager swift
modern creek
#

or use console.error

modern creek
#

then follow it

#

but also research on Google whether that style is correct or not