public static async Task <BloggerPostsResponse> GetAllPostsAsync() { // add a try/catch later HttpResponseMessage response = await _Client.GetAsync($"blogs/6944967079157211687/posts?key={_Bkey}"); if (response.IsSuccessStatusCode) { BloggerPostsResponse blogPosts = await response.Content.ReadAsAsync <BloggerPostsResponse>(); return(blogPosts); } else { return(null); } }
// GET: Blog public async Task <ActionResult> Blog() // to write async code had to change it to type from ActionResult -> Task<ActionResult> { BloggerPostsResponse allPosts = await GetAllPostsAsync(); return(View(allPosts)); }