From the course: Building React and ASP.NET Core Applications

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Read API endpoint

Read API endpoint

From the course: Building React and ASP.NET Core Applications

Start my 1-month free trial

Read API endpoint

- [Instructor] We know how to add new trips, but we still cannot get a list of trips so we know which places we have visited. For that, we need to go to our controller, so we can create a new API endpoint to get the list of trips. In here, go to Controllers, and then TripsController. Just before the AddTrip, we are going to add a new API endpoint, and since we are requesting for the data, we are going to create an HttpGetRequest. Now if we want, we can name this HttpGetRequest. So let's see, this is going to be a GetTrips. Now, down here write, public IActionResult, we're going to name the method GetTrips. What this method does? Is that, it will get a list of trips, so let's see var allTrips, this is equal to, we are going to use the injected service, so _service.GetAllTrips(). After we get the trips, we need to return them, so we're just going to write return ok(allTrips) and then semi-colon, now since the name of the…

Contents