Blazor demo: JS call, HttpClientFactory
Just a demo base on C# .NET Core Blazor Server project, with Javascript call/callback and HttpClientFactory, calling openweathermap to get weather forecast data.
1.HttpClientFactory [ref]
check
Startup.cs#L26
Data\OpenWeatherMapService.cs#L11-L18
2.Blazor Javascript call [ref]
check
wwwroot\js\Geolocation.js
Pages\FetchWeather.razor
Pages_Host.cshtml#L35
3.OpenWeatherMap API call was easy, please check Data\OpenWeatherMapService.cs
Result
It will require your geolocation by browser and get the city's weather forecast, if everything working fine.
Remember
Go OpenWeatherMap to get your API key and update it in here, the API key will need few time to active so you should do it first.