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:

https://www.getpostman.com/

We will also need to install the resource-router-middleware and enforce-content-type modules with NPM into our project's package.json file:

npm install --save resource-router-middleware enforce-content-type

These modules will help us make an easy job of mapping our resources to RESTful JSON standards in Express. For the purpose of locally testing our REST APIs, you may also want to temporarily remove our auth middleware from your /app.js API route configuration:

...
app.use('/api', api);
...

If you visit the localhost:3000/api API endpoint, get a status code of 200, and the response text API is running, then you should have an easy time moving forward with this recipe.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.241.51