'HttpClient' does not contain a definition for 'GetFromJsonAsync'

Viewed 4057

I created a new Blazor app and I want to access a URL through HttpClient I faced this error

'HttpClient' does not contain a definition for 'GetFromJsonAsync' and no accessible extension method 'GetFromJsonAsync' accepting a first argument of type 'HttpClient' could be found (are you missing a using directive or an assembly reference?) [BlazorApp]csharp(CS1061) ,

this is my code

 @inject HttpClient Http
    <h1>@name</h1>
    @code {
        private string name;
    
        protected override async Task OnInitializedAsync()
        {
            name = await Http.GetFromJsonAsync<string>("api/");
        }
    }
1 Answers
Related