8

Consuming Web APIs from Blazor WebAssembly

It’s time to feed our application and the page we have built with a real data source, let the app communicate with an online service to list the books available, and create the functionality for an admin to add new ones.

We will start this chapter by explaining why you need to communicate with an API from your Blazor app, in addition to understanding the built-in .NET class HttpClient, as well as other extensions that will be used to implement the communication with the API.

Next, we will practice sending GET and POST requests to our API. We will also explore some more advanced techniques to manage and manipulate HttpClient instances. We will use IHttpClientFactory and delegating handlers to apply ...

Get Mastering Blazor WebAssembly now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.