TryCatch hier unnötig
This commit is contained in:
@@ -11,10 +11,9 @@ namespace Jugenddienst_Stunden.Models {
|
||||
public Hours hours;
|
||||
|
||||
public static async Task<string> GetApiDataWithAuthAsync(string url, string token) {
|
||||
try {
|
||||
// Erstellen eines HttpClient-Objekts
|
||||
using (HttpClient client = new HttpClient() { Timeout = TimeSpan.FromSeconds(5) }) {
|
||||
try {
|
||||
|
||||
|
||||
client.DefaultRequestHeaders.Add("Accept", "application/json");
|
||||
|
||||
@@ -43,15 +42,7 @@ namespace Jugenddienst_Stunden.Models {
|
||||
// Lesen und Rückgabe der Antwort als String
|
||||
//string responseData = await response.Content.ReadAsStringAsync();
|
||||
//return responseData;
|
||||
} catch (HttpRequestException e) {
|
||||
// Fehlerbehandlung
|
||||
Console.WriteLine($"An error occurred: {e.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine(e.Message);
|
||||
return null;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user