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.

Mark as read

Mark as read

All right, so now we want to be able to mark our messages as read. We have the button here. And there's basically two parts to this. We want to be able to add the handler to click and then send the request to update the message to read. And then we also need to create the API route to do that. And as we've been kind of doing along in this course, I'd like to create the route first. So let's go to our app API folder. And then in messages, we're going going to need to create a new folder called brackets ID, because we need to update a specific message. And make sure that you're in the API messages folder, not just the app messages folder. And then inside that ID folder, we'll create our route.js file. And then from here, we're going to import a few things. Let's bring in ConnectDB. Let's bring in the message model. And let's bring in the getSessionUser that we created from the Utils. No, not that. We want getSessionUser from the Utils file. And then I'm also going to add this export…

Contents