Live Chat Icon For mobile
Live Chat Icon

How to use web api with Blazor client?

Platform: Blazor| Category: Web API

In the Blazor client-side application, you can call the web APIs using HttpClient service. In the following code, the GetData API is called on button click event. The GetFromJsonAsync method is used to get the parsed Json data.

@inject HttpClient Httpclient

<button @onclick="@GetData">Get Data</button>

@code {

    private async Task GetData()
        await Httpclient.GetFromJsonAsync<T>("api/GetData");

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.