From the course: Building React 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.

Delete API endpoint

Delete API endpoint

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

Start my 1-month free trial

Delete API endpoint

- The only thing that we cannot do right now in our app, is to be able to delete an existing trip. So that is what we're going to do now, by creating an API Endpoint, to delete data. So, let's go to Visual Code and see this in action. In here go to the Controllers folder, and then TripsController. Scroll down to the bottom. In here we are going to create our new API Endpoint. Since we want to delete data, we are going to send an HTTP DELETE request. And the url in here is going to be DeleteTrip. As part of the url, you're going to Trip ID as well. So I'll just write in here, (id). Now let's write public IActionResult DeleteTrip. And then you will write (int id). And then what we want to do is that we just want to use the _service, and then DeleteTrip. We pass as a parameter, the Trip ID, which is (id), in this case. And then we just return, ok(). Now, let us go to our service, so go inside…

Contents