I created my backlog with symfony, everything is ok, but now, I try to get my infos from the database.
My products will be owned by a category (which is an object), and I'm trying to display all my categories, but my TS request seems....bad.
Here is my code:
<ul>
<li *ngFor="let categorie of getAll()">{{ categorie }}</li>
</ul>
Component:
export class ShowCatComponent implements OnInit {
ngOnInit() { }
constructor(private categorieService: CategorieService) {
}
getAll() {
let categories;
categories = this.categorieService.getAllCategorie();
console.log(categories);
return categories;
}
}
service
getAllCategorie(): Promise<any> {
const UserToken = this.localStorage.get('userToken');
const jsonToken = JSON.parse(UserToken);
const httpOptions = {
headers: new HttpHeaders({
Authorization: jsonToken["token"]
})
};
return this.http.get(this.HTTP_URL + this.GET_CATEGORIES_URL, httpOptions).toPromise()
.then((response: Array<any>) => { return response.map(el => Categorie) });
}
This last request seems the problem, here is the log:
ERROR Error: Cannot find a differ supporting object '[object Promise]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
| async)