/BlazorExtensions

Usefull extensions for working with blazor

Primary LanguageC#

BlazorExtensions

Usefull extensions for working with blazor

Things I needed myself when experimenting with Blazor 0.2 preview, will probably become obsolete in newer versions.

Available on nuget.



Available methods:

void Browser.Alert(string message);
Trigger a browser alert('messsage') with your text.

string Browser.ReadStorage(string key)
Reads a value from the browser localstorage

void Browser.WriteStorage(string key, string value)
Writes a value to the browser localstorage

async Task<string> SendJsonAsyncRawResult(this HttpClient httpClient, HttpMethod httpMethod, string requestUri, object content)
Sends an HTTP Post request to the specified URI, including the specified content in JSON-encoded format, and does NOT parse the response body, just returns a string. Useful for requesting tokens

async Task<T> GetJsonAsync<T>(this HttpClient httpClient, string requestUri, string bearer)
Sends a GET request to the specified URI with an Auhtorization bearer in the header, and parses the JSON response body to create an object of the generic type.

async Task<T> PostJsonAsync<T>(this HttpClient httpClient, string requestUri, object content, string bearer)
Sends a POST request to the specified URI with an Auhtorization bearer in the header and the content object as JSON, and parses the JSON response body to create an object of the generic type.