...

/

Adding New Routes Part II

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 in books.ts in line 89. As stated earlier, we will be using a combination of getBook and addBook here. We’ll take three things as arguments: params, request and response.

  • We’ll use params ...