I'm getting error while retrieving data from the database.
Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
I tried all the remaining responses but I'm not getting the exact solution.
my service.ts:
users: User[];
getAllUsers(){
return this.http.get(environment.apiBaseUrl + '/users');
}
my component.ts:
refreshUserList(){
this.userService.getAllUsers().subscribe((res) => {
this.userService.users = res as User[];
})
};
my component.html:
<tr *ngFor="let use of userService.users">
<td>{{ use.fullName }}</td>
</tr>
So, use the below as you can see that the response is not an array but one of its fields is an array. So, you have to iterate on the array field.
*ngFor="let use of userService.users?.docs"