@page "/fetchdata"
@using TestApp02.Data
@inject WeatherForecastService ForecastService
Weather forecast
Weather forecast
This component demonstrates fetching data from the server.
@if (forecasts == null)
{
}
else
{
Date
Temp. (C)
Temp. (F)
Summary
@context.Date
@context.TemperatureC
@context.TemperatureF
@context.Summary
}
@code {
private WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
}
}