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)); }
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)); }
public static string ToJson(this DadJoke self) => JsonConvert.SerializeObject(self, HelloJokes.Core.Converter.Settings);