If you want to check if the data returned by our service is an Array or a simple object we can use the Array.isArray(**) function
Example :
this._Service.getList().subscribe(
(data) => {
if (Array.isArray(data)) {
this.dataSource = new MatTableDataSource(data);
}
else {
this.dataSource = new MatTableDataSource([data]);
}
here we added [data] when the service returns an object to make sure that we are affecting an array to our dataSource