Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
using Newtonsoft.Json;
using System.Diagnostics;
namespace WeatherApp
{
public class RestService
{
HttpClient _client;
public RestService()
{
_client = new HttpClient();
}
public async Task<WeatherData> GetWeatherData(string query) {
WeatherData weatherData = null;
try
{
var response = await _client.GetAsync(query);
if (response.IsSuccessStatusCode) {
var content = await response.Content.ReadAsStringAsync();
weatherData = JsonConvert.DeserializeObject<WeatherData>(content);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
throw;
}
return weatherData;
}
}
}