For some reason declaring ApiResult
before checking if the answer is in a correct status doesn't look good. I wonder if there is any better way to check the status and return the result:
public async Task<ApiResult> GetCustomersByOutcode(string outcode)
{
using (var client = new HttpClient())
{
ConfigureHttpClient(client);
var response = await client.GetAsync(
$"customer?q={WebUtility.UrlEncode(outcode)}");
ApiResult result = null;
if (response.IsSuccessStatusCode)
{
result = await response.Content.ReadAsAsync<ApiResult>();
}
return result;
}
}