My service includes a method called getCategory()
that retrieves categories from the server. The method looks like this:
getCategory(): Observable<CategoryModel[]> {
return this.http.get<CategoryModel[]> (this.productUrl)
.pipe(
catchError(this.handleError('getHeroes', []))
);
}
Within my component, I aim to store the retrieved data in an array named categoryList: CategoryModel[];
using the following method:
getCategory(): void {
this.dataStorageServiceService.getCategory()
.subscribe(
(categories: CategoryModel[]) => {
this.categoryList = categories;
console.log(this.categoryList)
}
}
The output of categoryList
is displayed as an Object, and unfortunately, I am unable to render it on the template.