Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Blazor Books component accessing an Azure Function returning Book objects
@page "/books"
@using BooksLib
@inject HttpClient Http
<h1>Books Sample</h1>
<p>This component demonstrates fetching data from Azure Functions.</p>
<p>Status: @message</p>
@if (books == null)
<table class="table">
@foreach (var book in books)
@functions {
Book[] books;
string message;
protected override async Task OnInitAsync()
message = "OnInitAsync";
Http.BaseAddress = new Uri("");
books = await Http.GetJsonAsync<Book[]>("/api/BooksFunction");
message = "downloaded books";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment