Issue
I get my data from my API, I have already made my call and I display it.
I would like to order it alphabetically.
I don't understand why my console say : 'ERROR TypeError: Cannot read properties of undefined (reading 'sort')'
Solution
Because you are getting the clubs in one async operation and you launch sort operation immediately and the data didn't arrive yet. You must chain the operation:
constructor(...) {
this.getClubs().subscribe(clubs => {
this.clubs = clubs;
this.sortClubs();
});
}
private getClubs() {
return this.httpClient.get('...')
}
Answered By - PeS
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.