Create Service
In this step of this tutorial, we will create a service that will consume the API route that we have defined in the backend such that we retrieve the list of the books. We will then modify our list-book component so that the list of books is displayed.
This process is somehow a little bit similar to the backend part, we start first by creating a book model. In the "src/app/shared/models" we create a new file "book.model.ts" and we add the following code:
Also we add the following line in "index.ts" that is in "src/app/shared/models".
Now, through the console we navigate to the following path:
and we type in the console:
We now need to consume the API route that we have created in the backend. To do so, we modify the "bms.service.ts" file to the following:
We need to check to add in our index.ts that is in "src/app/shared/services".
Last updated