InvalidOperationException: An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.(HttpClient httpClient, string requestUri)
public class IndexBase:ComponentBase
{
public readonly HttpClient httpClient = new HttpClient();
public IEnumerable<Category> categories { get; set; }
protected override async Task OnInitializedAsync()
{
categories= await httpClient.GetJsonAsync<Category[]>("api/Category");
}
}
and add code in startup
services.AddHttpClient("ServerApi",clint =>
{
clint.BaseAddress = new Uri("https://localhost:44363/");
});