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

Unlock the full course today

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

Adding new data from React

Adding new data from React

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

Start my 1-month free trial

Adding new data from React

- (Narrator) We created the form for adding new trips. Now let us see how to get the form data and send a request to the web API. For that, let's go to Visual Code. In here, go to ClientApp, then src, components, Trip, and then Create file. The first thing that we need to do in here is that we need to tie all the input fields to the state fields. So for that, let's go to the form. Now in here we need to set the value property to all the input fields. So let us scroll down in here and write value. The value is going to be this.state.name. Let us do the same for the description. So for that, we just write value is equal to this.state.description. Then for the date of start. So value is equal to this.state.dateStarted. And let's do the same for the dateCompleted. So here, let us just change it to dateCompleted. Another thing that we need to do in here is that we need to add the onChange event. So when the user changes the…

Contents