/Study-DELETE-Endpoints-Functionality

A handy study in DELETE endpoints functionality with a practical example demonstrating delete requests from a client to remove an item from a list (and subsequent requests will show item removed).

Primary LanguageJavaScript

DELETE Endpoints Functionality Study


What is DELETE Endpoints Functionality Study?

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();                                                        
                  });

Does DELETE Endpoints Functionality Study feature commentary?

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.


What are the key features of DELETE Endpoints Functionality Study?

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)

Screenshots

delete1 delete2 delete3