expose-myit/Client/Pages/FetchData.razor.cs
2022-12-10 12:06:16 -07:00

22 lines
738 B
C#

using Expose.MyIT.Shared.ViewModels;
using Microsoft.AspNetCore.Components;
using System.Net.Http.Json;
namespace Expose.MyIT.Client.Pages;
public partial class FetchData
{
[Inject] protected HttpClient? Http { get; set; }
private WeatherForecast[]? _Forecasts;
protected override async Task OnInitializedAsync()
{
if (Http is null)
throw new NullReferenceException(nameof(Http));
string controllerName = MyIT.Shared.Models.Stateless.Methods.IWeatherForecastController.GetRouteName();
// _SsaOrders = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
_Forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>($"api/{controllerName}");
}
}