19 lines
462 B
C#
19 lines
462 B
C#
using System.Text.Json;
|
|
|
|
namespace ReportingServices.Shared.Blazor.HelperClasses;
|
|
|
|
public static class ApiCaller
|
|
{
|
|
public static async Task<T> GetApi<T>(string url)
|
|
{
|
|
T deserializedJson = default;
|
|
|
|
using (HttpClient client = new())
|
|
{
|
|
string apiResponse = await client.GetStringAsync(url);
|
|
deserializedJson = JsonSerializer.Deserialize<T>(apiResponse);
|
|
}
|
|
|
|
return deserializedJson;
|
|
}
|
|
} |