async void callweatherapi()
{
string apiKey = "kanyecooked";
string city = Citysearch.Text;
string apiUrl = $"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={apiKey}&units=metric";
using (HttpClient client = new HttpClient())
{
try
{
HttpResponseMessage response = await client.GetAsync(apiUrl);
response.EnsureSuccessStatusCode();
string json = await client.GetStringAsync(apiUrl);
WeatherConditions.Rootobject weatherdetails = JsonConvert.DeserializeObject<WeatherConditions.Rootobject>(json);
forcastinfo.Text = weatherdetails.weather[0].main;
windspeedinfo.Text = weatherdetails.wind.speed.ToString();
if(weatherdetails == null)
{
Debug.WriteLine("no data");
}
}
catch (Exception ex)
{
Console.WriteLine("Did not work"+ex.Message);
}
}
}
async void callweatherapi()
{
string apiKey = "kanyecooked";
string city = Citysearch.Text;
string apiUrl = $"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={apiKey}&units=metric";
using (HttpClient client = new HttpClient())
{
try
{
HttpResponseMessage response = await client.GetAsync(apiUrl);
response.EnsureSuccessStatusCode();
string json = await client.GetStringAsync(apiUrl);
WeatherConditions.Rootobject weatherdetails = JsonConvert.DeserializeObject<WeatherConditions.Rootobject>(json);
forcastinfo.Text = weatherdetails.weather[0].main;
windspeedinfo.Text = weatherdetails.wind.speed.ToString();
if(weatherdetails == null)
{
Debug.WriteLine("no data");
}
}
catch (Exception ex)
{
Console.WriteLine("Did not work"+ex.Message);
}
}
}