I am trying to use this in a method call to get a string from a source
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync(url);
string responseBody = await response.Content.ReadAsStringAsync();
Console.Write(responseBody);
When used outside of a method and class, it works fine with my url, and returns the proper string I am looking for. However, when I put it in my class and method, it no longer does anything. No errors, just returns nothing.
For reference, the method I am using looks like this
public async void get(String test) {
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync(test);
string responseBody = await response.Content.ReadAsStringAsync();
Console.Write(responseBody);
}
I am clueless why this stops working once I put it into a method.