From the course: Angular: Creating and Hosting a Full-Stack Site

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create an endpoint to delete listings

Create an endpoint to delete listings

From the course: Angular: Creating and Hosting a Full-Stack Site

Start my 1-month free trial

Create an endpoint to delete listings

- [Instructor] So now we've come to our last route and that's the route that will allow users to delete listings. So here's what that'll look like. Let's create a new route file called deleteListing.js. And then we're going to implement the route like this. We're going to say import db from ../database. And then export const deleteListingRoute. And the method for this route is actually going to be delete, which is just another method that the client can send like get or post. And the path is going to be /API/listings/{id}. And then for the route handler, it's going to be async. And inside there, we're going to get this ID URL parameter by saying const id equals request.params. And just as a side note, at some point here too we're going to want to check to make sure that the client who's sending this request is actually the owner of this listing 'cause otherwise users would be able to delete each other's listings, which obviously…

Contents