Viewing a Single Item
At this point, your application can query the to-do REST API for all items. Let’s add the ability to get details for a specific item.
The to-do REST API returns information about a single item by querying the URL /todo/id using the HTTP Get method. The id is a numeric identifier that represents an item from the list. You can find the item id using the list command. When you’re working with an API you’re unfamiliar with, consult the REST API documentation to understand how to make queries for particular resources that you’re interested in.
To obtain a single item from the REST API, first add a new function to the cmd/client.go file. This function wraps the getItems function similarly to the getAll function you developed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access