Adding New Routes Part II
In this lesson, we'll add the last two routes left in our CRUD REST API.
We'll cover the following...
Update a book
Now that we’ve learned how to get books and even add one, it’s time we learned how to update an existing book in our REST API. Spoiler alert: This will be a combination of getBook
and addBook
. Why do we need such a functionality? Maybe we made a typo somewhere or stored the wrong data.
export interface IBook { id: string; name: string; author: string; genre: string; }
-
Let’s have a look at the
updateBook
method inbooks.ts
inline 89
. As stated earlier, we will be using a combination ofgetBook
andaddBook
here. We’ll take three things as arguments:params
,request
andresponse
. -
We’ll use
params
...