The "DELETE Endpoints Functionality Study" demonstrates the basic functionalities of a DELETE request wherein the client removes an item from a list and any subsequent GET request will show the item removed.
In an express application, to handle a DELEET request, you call the app object (note the use of const app = require('express')
which instantiates the app and allows us to use express) with the DELETE method. The DELETE method is pretty straight forward. In the route handler, you need to provide the route AND the id of the item that you want to delete. Then, when you request for the item to be deleted (i.e. req.params.id), you call the model and method (i.e. List.delete).
app.delete('/list/:id', (req, res) => {
List.delete(req.params.id);
console.log(`Deleted list item \`${req.params.id}\``);
res.status(204).end();
});
Yes! The DELETE Endpoints Functionality Study features commentary in the server.js file to show the structural context and implementation of POST endpoint functionality. In addition, I also provide a Process text file that gives a good outline of the implementation process.
Since this study is ongoing, basic functionalities are covered first and more advanced features are added or will be added in the future:
Features: | Feature Notes: |
---|---|
DELETE request to localhost:8080/shopping-list/:id | This DELETE request will remove an item (and another GET request show it is gone) |