categories.component.html:
<div class="right-widget categories">
<h3>Categories</h3>
<ul>
<li *ngFor="let category of categories">
{{category.name}}
</li>
</ul>
</div>
export class BlogpostService {
getFeaturedBlogs() {
throw new Error("Method not implemented.");
}
ServerUrl = 'http://localhost/demo/blogger/';
errorData: {};
constructor(private http: HttpClient) { }
getBlog(id: number) {
return this.http.get<Blogpost>(this.ServerUrl + 'api/blog/' + id)
.pipe(
catchError(this.handleError)
);
}
getRecentBlogs() {
return this.http.get<Blogpost>(this.ServerUrl + 'api/recent_blogs').pipe(
catchError(this.handleError)
);
}
getCategories() {
return this.http.get<Category>(this.ServerUrl + 'api/categories').pipe(
catchError(this.handleError)
);
}