Files
Biblotek/Bokhantarare/Helper.cs
Zacharias 3c44c8dc8a Chaged colors
Added handelrs for networking exceptions
Made Book selector a bit bigger
Fixed issue with publishing date
2025-02-04 09:03:10 +01:00

29 lines
830 B
C#

using System.Net.Http;
using System.Net.Http.Headers;
namespace Bokhantarare;
public class Helper
{
public static string? Request(string requestUrl)
{
try
{
HttpClient client = new HttpClient();
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, requestUrl);
requestMessage.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json"));
//Connect to the URL
HttpResponseMessage response = client.SendAsync(requestMessage).Result;
// Get the response
string Output = response.Content.ReadAsStringAsync().Result;
return Output;
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
return null;
}
}
}