AM
Size: a a a
AM
S
S
S
ZK
AM
@using System.Net.Http
@inject HttpClient Http
<input @bind="newItemName" placeholder="New Todo Item" />
<button @onclick="@AddItem">Add</button>
@code {
private string newItemName;
private async Task AddItem()
{
var addItem = new TodoItem { Name = newItemName, IsComplete = false };
await Http.PostAsJsonAsync("api/TodoItems", addItem);
}
}
S
AM
builder.Services.AddScoped(sp =>
new HttpClient
{
BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
});
S
ZK
S
AM
S
S
AM
@inject HttpClient Http
@code {
private TodoItem[] todoItems;
protected override async Task OnInitializedAsync() =>
todoItems = await Http.GetFromJsonAsync<TodoItem[]>("api/TodoItems");
}
ZK
@inject HttpClient Http
@code {
private TodoItem[] todoItems;
protected override async Task OnInitializedAsync() =>
todoItems = await Http.GetFromJsonAsync<TodoItem[]>("api/TodoItems");
}
ZK
S
S
МЕ