From the course: Node.js: Web Servers, Tests, and Deployment
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Handling DELETE requests - Node.js Tutorial
From the course: Node.js: Web Servers, Tests, and Deployment
Handling DELETE requests
- [Instructor] There's one last thing to do. If we go to the Network tab, and then we click on the trashcan icon next to one of these terms, and then we say OK, we're noticing that there's a 404 error here. There's some sort of a problem. Cannot DELETE /dictionary/huck. Our client is trying to send a delete request to our API. And the term that the client wants to delete is being described by the route itself, /dictionary/huck. So no problem. Express automatically handles routing parameters for us, which makes it easier to capture and use this data. So let's go ahead and add a delete route to our API. All right, so we want to call app.delete. We're going to use dictionary/ and then we'll use a parameter here. We know it's a parameter because we use the colon. So whatever that term is. Huck, drop, whatever. So that'll take the place of that term. Then we want to call a callback function, request and response, and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.