I have some code that's bugging me due to my lack of knowledge on Async in c#.
public async Task<T> GetAsync(string apiURL)
{
_client = await SchedulerHttpClient.ClientTask;
var response = await _client.GetAsync(apiURL);
if(response.IsSuccessStatusCode)
{
var responseContent = response.Content.ReadAsAsync<T>();
//todo: check
return responseContent.Result;
}
else
{
return default(T);
}
}
My question is i want to get the content from the response, in my example i await the response so i can obtain the content.
However should i use await to get the content, if not then how do i get the content from the response if i don't await.