@page "/fetchdata" @using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Components.WebAssembly.Authentication @using Start.Shared @attribute [Authorize] @inject HttpClient Http

Weather forecast

This component demonstrates fetching data from the server.

@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() { try { forecasts = await Http.GetFromJsonAsync("WeatherForecast"); } catch (AccessTokenNotAvailableException exception) { exception.Redirect(); } } }