Ooui-tws-port/Samples/WeatherApp/DataService.cs

25 lines
662 B
C#
Raw Normal View History

2017-12-12 20:43:38 +00:00
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Net.Http;
using Newtonsoft.Json.Linq;
namespace WeatherApp
{
public class DataService
{
public static async Task<JContainer> getDataFromService(string queryString)
{
HttpClient client = new HttpClient();
var response = await client.GetAsync(queryString);
JContainer data = null;
if (response != null)
{
string json = response.Content.ReadAsStringAsync().Result;
data = (JContainer)JsonConvert.DeserializeObject(json);
}
return data;
}
}
}