Exemple #1
0
        public async Task <Jokes> GetTermJoke(string term)
        {
            HttpClient client = GetHttpClient();

            client.DefaultRequestHeaders.Add("Accept", "application/json");
            var response = await client.GetAsync($"search?term={term}");

            Jokes jokes = await response.Content.ReadAsAsync <Jokes>();

            return(jokes);
        }
Exemple #2
0
        public async Task <Jokes> GetRandomJokes()
        {
            HttpClient client = GetHttpClient();

            client.DefaultRequestHeaders.Add("Accept", "application/json");
            var response = await client.GetAsync("search");

            Jokes jokes = await response.Content.ReadAsAsync <Jokes>();

            return(jokes);
        }
Exemple #3
0
        public async Task <Jokes> GetMore(int nextPage, string term)
        {
            HttpClient client = GetHttpClient();

            client.DefaultRequestHeaders.Add("Accept", "application/json");
            if (term == null)
            {
                var response = await client.GetAsync($"search?page={nextPage}");

                Jokes jokes = await response.Content.ReadAsAsync <Jokes>();

                return(jokes);
            }
            else
            {
                var response = await client.GetAsync($"search?page={nextPage}&term={term}");

                Jokes jokes = await response.Content.ReadAsAsync <Jokes>();

                return(jokes);
            }
        }