@page "/fetchdata" @using LiveChat.Data @inject WeatherForecastService ForecastService Weather forecast

Weather forecast

This component demonstrates fetching data from a service.

@if (forecasts == null) {

Loading...

} else { @foreach (var forecast in forecasts) { }
Date Temp. (C) Temp. (F) Summary
@forecast.Date.ToShortDateString() @forecast.TemperatureC @forecast.TemperatureF @forecast.Summary
} @code { private WeatherForecast[]? forecasts; protected override async Task OnInitializedAsync() { forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now)); } }