Notes Display
Learn to create an API to read and render a note from the database.
We'll cover the following...
We'll cover the following...
Reading a note
In this lesson, we are going to implement a route/API that shows the details of a note.
Let’s start by defining a new route in the routers/route.go file.
Line 14: The route with the pattern /notes/:id([0-9]+) uses the GET method to trigger the NotesShow() action, where :id is a placeholder for the note’s numerical Id. Therefore, requesting /notes/1 would fetch and render the note with Id 1 from the database.
Handler function
The NotesShow() function is responsible for showing a note. Details of the function are as follows: ...