Consuming a REST API in Blazor components
Up till now, we were focusing on the server side of the project. Now it is time to create some Blazor components and start using the code that we have already created. For our application, we will need two main components:
- DataForm: This component will take care of forms in our application and allow us to create and edit records
- DataView: This component will render a table to present existing data to the user
Creating and editing data
The Microsoft Blazor team has already created a lot of components that we can use. InputText
, InputDate
, InputTextArea
, and many more form elements are already created for us. These form elements must be wrapped around the EditForm
component to work properly.
The EditForm
component will render the HTML form
tag and provide the validation and submission logic to us. We don’t want to write each detail (for the Person
and Movie
entities) from scratch, so we will prepare a single component...