issue getting dynamic route params on live site vercel
Unanswered
Pixiebob posted this in #help-forum
PixiebobOP
Im having issues right now trying to get my production site to retrieve params from my dynamic route, which works locally, but ive been having issues trying to get it to work on vercel.. Please look at my code, i can answer questions, just super confused what ive messed up , ive been trying to figure out what the problem is.
app/profile/[userID]/page.jsx:
im routing to these using Link, with this as the href for each one , <Link href={
app/profile/[userID]/page.jsx:
'use server'
import { fetchUser } from '../../lib/fetchUser'
import { fetchUserPosts } from '@/app/lib/fetchPosts'
import ProfileHeader from '../../components/ProfileHeader'
import ProfileContent from '../../components/ProfileContent'
import { auth } from '@clerk/nextjs/server'
import Link from 'next/link'
export default async function page({ params }) {
console.log("Params:", params);
const { userID } = params;
const { userId } = await auth();
console.log("UserID:", userID);
console.log("Clerk userId:", userId);
const [user, posts] = await Promise.all([
fetchUser({ userId: userID }),
fetchUserPosts({ userId: userID }),
]);
return (
<div className='bg-[#200c22] text-white pt-12'>
<div className='border-b-[#a086b2] border-b-2'>
<ProfileHeader user={user} clerkUserId={userId} />
</div>
{posts.length === 0 ? (
<div className='flex flex-col justify-center gap-4 align-middle items-center h-full min-h-72 text-lg'>
<p className=''>No posts yet!</p>
<Link className='p-2 bg-purple-500 rounded-lg' href={'/create-post'}>Create Post</Link>
</div>
) : (
<ProfileContent posts={posts} />
)}
</div>
);
}
im routing to these using Link, with this as the href for each one , <Link href={
/profile/${iD}
} className='font-semibold text-white hover:text-[#a086b2] text-1xl'>{userName}</Link>9 Replies
PixiebobOP
ive collected clerkUserId, and regular id in my db, (i had originally built it out like this but ive realized i could have done this better) im only using it for conditional rendering of an edit profile button so that they can edit their own profile, but not think that they can edit others.
Asian black bear
First of all remove the
'use server'
directive, because it doesn't do anything there. Second, what's the output of the first console.log
?PixiebobOP
params: %5BuserID%5D ,
I guess i just realized its screwed up
I guess i just realized its screwed up
thats userID sorry, i renamed it to params
im pretty sure thats how curly braces look, i just dont understand how thats returning from the promise hm.
PixiebobOP
PixiebobOP
ok i fixed that issue now its showing the correct id
{userID: '558d3c75-0a77-4f63-941b-16c2d833b308'}
but when i get into vercel, it just keeps giving me this.
but when i get into vercel, it just keeps giving me this.
Asian black bear
This means some property
clerkUserId
was undefined
. You'll have to debug this and if you need additional help after trying to solve it youself you're welcome to open another thread with more specific details since this thread was for another issue altogether.