@page "/test"
@using System.Net.Http.Json
@using System.Text.Json
@inject HttpClient httpClient
@if (data != null)
{
@foreach (var component in data) {
switch (component.Type) {
case 0:
break;
case 1:
break;
}
}
}
@code {
private Component[] data;
protected override async Task OnInitializedAsync()
{
var response = await httpClient.GetStringAsync("http://localhost:8080/schema");
var options = new JsonSerializerOptions {PropertyNameCaseInsensitive = true};
var json = JsonSerializer.Deserialize(response, options);
data = json.components;
}
}