Creating Resources

Learn how to create resources in a NestJS application.

Building on our previous work, we’ll now expand our virtual library by allowing the addition of new books to our books-api. Our library will grow with every new addition. This section will enhance our virtual library with book creation functionality.

Updating BooksController

Our application will have a route to add new books. In line with HTTP standards, we’ll use the POST HTTP method, designed for sending data to create a new resource. Let’s create our route by following these steps:

  1. Import the corresponding decorator for the Post request and the Body decorator in the BooksController file:

Get hands-on with 1400+ tech skills courses.