From the course: Building Angular and ASP.NET Core Applications
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Read API endpoint
From the course: Building Angular and ASP.NET Core Applications
Read API endpoint
- [Instructor] The users want to be able to see what they have in their collection and so we need to implement a feature that will return all their books. For that, we'll create a read API endpoint. So, let's go to Visual Code and see this in action. And here go inside the Controllers, then BooksController.cs. After the AddBook we are going to add a new API endpoint. So, read all books. This is going to be an HTTP get request and the name of the URL is going to be the same as the action name, so for that we just write inside double quotes, square brackets, and then action. Next, we define the implementation. So for that we write public IActionResult, then GetBooks, then inside here we write var allBooks. We are going to use the service, so service.GetAllBooks. And once we have the books, we want to return them to the users by writing return Ok and then inside here allBooks. Let us press Enter and save the changes.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.