Building a Basic Todo List REST API in Node.js with Express

ACT
66.5K views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Parameters

Express allows to extract parameters from the url. A parameter is defined in an URL with the ":" prefix. It is aviailable as a member of request.params.

var myParam = request.params.myParam

Route parameters are named URL segments that are used to capture the values specified at their position in the URL. The captured values are populated in the req.params object, with the name of the route parameter specified in the path as their respective keys.

from http://expressjs.com/en/guide/routing.html

Exercise: Complete the PUT function

Last Action: DELETE

To conclude this part of the tutorial, please find bellow a basic implementation of the DELETE method.

DELETE Method

As you can see, all the code is in one file, we do not have a clear separation of each layer. Let's move on how the next page to add a database and also refactor and organize our code with modules.

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content