Calling REST API from BLAZOR Application

In this article, we will see how to consume REST API calls inside blazor application,

Initially, we are loading the data by hard coding the values in component base file lets look at the code for that,



So as you see over here we are hard coding the values and displaying it on component now instead we will get the product list from database calling a rest api defined method for that we are defining service to get that data,



As you see over here we used HttpClient to make a call to our endpoint for that you need to register this service in ConfigureService as shown below,

Here, we registered HttpClient with respective service in Dependency injection container and also specified the base address of the client.

Once these changes are done then we need to inject the service in the component base class to fetch the required data as shown below,


Thank You, See you in the next article !!

You can reach out to me here,



If you want some technical topics to be discussed with group of participants please raise a request on following link:

Technical Speaker | Computer Engineer | Full Stack Web Developer | ML Enthusiast | * Knowledge Shared = Knowledge² *