-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components
Description
Hi
I have created a new blazor component and tried to call get data from json file.
@function {
protected override async Task OnInitAsync()
{
data = await Http.GetJsonAsync<GridItem[]>("sample-data/data.json");
}
}
And got this error:
Uncaught (in promise) Error: System.InvalidOperationException: Cannot provide a value for property 'Http' on type 'BlazorGrid.App.Components.GridComponent'. There is no registered service of type 'System.Net.Http.HttpClient'.
at Microsoft.JSInterop.DotNetDispatcher.InvokeSynchronously(String assemblyName, String methodIdentifier, Object targetInstance, String argsJson)
at Microsoft.JSInterop.DotNetDispatcher.BeginInvoke(String callId, String assemblyName, String methodIdentifier, Int64 dotNetObjectId, String argsJson)
at endInvokeDotNetFromJS (components.server.js:23)
at components.server.js:23
at new Promise (<anonymous>)
at e.beginInvokeJSFromDotNet (components.server.js:23)
at components.server.js:16
at Array.forEach (<anonymous>)
at e.invokeClientMethod (components.server.js:16)
at e.processIncomingData (components.server.js:16)
at e.connection.onreceive (components.server.js:16)
at WebSocket.i.onmessage (components.server.js:16)
What's wrong here?
This is working in Blazor 0.7, but not working in Blazor 0.8
Metadata
Metadata
Assignees
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components