Player API and client controllers

This commit is contained in:
2020-02-29 22:11:22 +01:00
parent 1d39ae9537
commit ab43075df8
7 changed files with 146 additions and 16 deletions

View File

@@ -55,6 +55,8 @@ namespace EstusShots.Client
var response = await HttpClient.PostAsync(url, content);
response.EnsureSuccessStatusCode();
var json = await response.Content.ReadAsStringAsync();
if (json.IsNullOrWhiteSpace() || json == "{}")
return new ApiResponse<TResult>(new OperationResult(false, "Invalid response", "The server returned no or empty data"));
var result = JsonSerializer.Deserialize<ApiResponse<TResult>>(json, _serializerOptions);
return result;
}