I'm using the Angular Material table component like so:
this.userService.getUsers().subscribe((response) => {
this.users = new MatTableDataSource(response);
});
It works but when compiling it throws the following typescript error:
Argument of type 'Object' is not assignable to parameter of type '{}[]'. The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? Property 'includes' is missing in type 'Object'.
So I tried changing it to:
this.users = new MatTableDataSource<any>(response);
But still same error. response
looks like this:
[{
userId: 123,
username: 'Tom'
}, {
userId: 456,
username: 'Joe'
}]
Any idea how to get rid of the error?
EDIT
Should mention if I do this:
this.users = new MatTableDataSource([response]);
the error goes away but then the table doesn't work because the format isn't the right one that's expected by the table. Just noting this in case it sheds any light as to what may be the cause...