mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-05 05:27:37 +08:00
15 lines
400 B
C#
15 lines
400 B
C#
using System.Net.Http;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AntBlazor
|
|
{
|
|
public static class HttpClientExtensions
|
|
{
|
|
public static async ValueTask<T> GetJsonAsync<T>(this HttpClient httpClient, string url)
|
|
{
|
|
var s = await httpClient.GetStreamAsync(url);
|
|
return await JsonSerializer.DeserializeAsync<T>(s);
|
|
}
|
|
}
|
|
} |