Tutorial: Get all books
What you’ll learn
In this tutorial, you learn the operations to call to get all books from the Book Buddy database.
Expect this tutorial to take about 15 minutes to complete.
Before you start
Make sure you’ve completed the Before you start a tutorial topic on the development system you’ll use for the tutorial.
Get all books
To get all books from the database, you’ll use the GET method to retrieve all books resources from the service.
In this tutorial, you’ll use the Postman app.
To get all books:
-
Make sure your local service is running. If it’s not, start it by using this command.
cd <your-github-workspace>/book-buddy-api/api json-server -w book-buddy-api-source.json -
Open the Postman app on your desktop.
- In Postman, create a new request with these values:
- METHOD: GET
- URL:
/books - Headers:
Content-Type: application/json
- In the Postman app, choose Send to make the request.
-
Check the response body. It should look something like this.
[ { "id": 1, "title": "How to be happy", "author": "Ruskin Bond", "genre": "Memoir", "readingStatus": "0 %", "rating": "0" }, { "id": 2, "title": "Verity", "author": "Collen Hoover", "genre": "Thriller", "readingStatus": "70 %", "rating": "5" }, ... ]
After doing this tutorial in Postman, you might like to repeat it in your favorite programming language. To do this, adapt the values from the tutorial to the properties and arguments that the language uses to make REST API calls.