Building REST APIs with Express
Let's create a simple REST API to replace our /posts
route for our blog. The API will be able perform the create, read, update, and delete (CRUD) actions for blog posts for our web application. Express middleware can serve as a helpful, reusable layer for configuring our RESTful API to make sure that any future APIs we want to implement can be done in a consistent way.
Getting ready
When working on developing REST APIs, it can be very useful to have a client other than your application handy for hitting API endpoints and checking the format of the response data. You can use anything from a simple curl
command to a wide variety of REST API client applications to do this. For those unfamiliar with such tools, I recommend that you download the free REST API client, Postman. It is available for virtually every operating system and provides a simple and robust toolkit for testing your REST APIs.
You can download the Postman API client from its official website: