Querying the API using test data
We need some test data in order to test our service, so let's use the catalog.json
file in the data
directory of our project. This data will allow us to test all our three functions, but to do that, we would need a client that can send REST requests against an endpoint. If you still haven't created a Postman project for testing your application, now is an appropriate time to create it.
Requesting /catalog
should return all the categories in the test
file:

Thus, requesting/catalog/1
should result in returning a list with all the items under the Watches
category:

Finally, requesting http://localhost:3000/catalog/1/item-identifier-1
would display only the item identified by item-identifier-1
, and requesting a nonexistent item would result in response with status code 404
:
