public async Task <DadJoke> GetJoke()
        {
            var client = new HttpClient();

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var responseJson = await client.GetStringAsync("https://icanhazdadjoke.com");

            return(DadJoke.FromJson(responseJson));
        }
示例#2
0
        public async Task <DadJoke> GetJoke()
        {
            var client = new HttpClient();

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var jokeResonseJson = await client.GetStringAsync(jokeUrl);

            return(DadJoke.FromJson(jokeResonseJson));
        }
示例#3
0
 public static string ToJson(this DadJoke self) => JsonConvert.SerializeObject(self, HelloJokes.Core.Converter.Settings);