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.

Fetch featured properties

Fetch featured properties

All right, guys, so now we're going to do the featured properties. And this is completely optional. I just think it fills out the home page a little better. So we're just going to have two differently formatted cards above the recent properties for featured properties. And this would be a good way to maybe make some money. You could have people pay you to put the listings featured on the home page in addition to the random properties we have here. All right, now we want to go to the database. And I've already changed two of the properties to have this isFeatured flag, which you should already have in there. And it's false by default, but I changed two of them to true, this Modern Downtown Studio, and what was the other one, the Cozy Downtown Loft. So just pick two and set isFeatured to true, either through Compass, or you can do it through Atlas through the browser. All right, so now we're going to start off by creating the API route. So let's go to App, API, Properties. Now, you…

Contents