protected override async Task OnInitializedAsync() { List <BlogPosts> blogs = await BlogService.GetBlogsAsync(); thisblog = blogs.FirstOrDefault(x => x.Slug == Slug && x.Published); if (thisblog != null) { thisblogsingle = await BlogService.GetBlogPostAsync(thisblog.Id); } this.StateHasChanged(); }
public async Task <BlogPostsSingle> GetBlogPostAsync(int id) { var call = Client.GetAsync(new Uri(Client.BaseAddress + "articles/" + id.ToString())); HttpResponseMessage httpResponse = await call; string result = await httpResponse.Content.ReadAsStringAsync(); BlogPostsSingle post = JsonConvert.DeserializeObject <BlogPostsSingle>(result); httpResponse.Dispose(); return(post); }