From the course: Next.js 14 from Scratch: Build a Real-World Project Using Next.js 14 and MongoDB

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

User profile listings

User profile listings

So now we want to put the profile listings on the page, because right now these are just hard-coded HTML. So first thing I want to do is create the API route to get the user's listings. Now there's really two ways we could do this. We could make it so that we hit just like slash API slash property slash user, and then get the user from the session, which would make it so only that user could get the listings. or we can make it so that we can use the user ID in the API URL. But then anyone could get anyone's listings, which in this case, that's what I'm going to do, because I don't have a problem with that. In fact, that might be something you want to do later, is make it so that someone can click on anyone's name or image or whatever and get that user's listings. So it's up to you on how you want to do it. I'm going to put the user ID right in the URL, which means anyone could get anyone's listings. Not edit them or delete them or anything like that. Just see the other person's…

Contents