2023-01-11 10:00:39 -07:00

23 lines
597 B
C#

using ReportingServices.Shared.Models.ProductionReport;
using System.Net.Http.Json;
using System.Text.Json;
namespace ReportingServices.Shared.HelperClasses
{
public static class ApiCaller
{
public static async Task<T> GetApi<T>(string url)
{
T deserializedJson = default(T);
using (HttpClient client = new())
{
string apiResponse = await client.GetStringAsync(url);
deserializedJson = JsonSerializer.Deserialize<T>(apiResponse);
}
return deserializedJson;
}
}
}