Exemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            List <Book> books = new List <Book>();

            HttpClient          client       = _bookAPI.InitializeClient(_configuration);
            HttpResponseMessage httpResponse = await client.GetAsync("api/book");

            if (httpResponse.IsSuccessStatusCode)
            {
                var result = httpResponse.Content.ReadAsStringAsync().Result;
                books = JsonConvert.DeserializeObject <List <Book> >(result);
            }
            return(View(books));
        }