A nested object is showing up as [object Object] so I'm trying to cast it via pipe and map but I'm not getting any where. I've tried the models as classes and interfaces but no help. Can someone tell me what I'm doing wrong? Thanks.
The function:
getClients(customerId: number): Observable<Client[]> {
let clientUrl = 'SOME_URL';
return this.http.get<Client[]>(clientUrl)
.pipe(map(client: Client) => client.address as Address);
}
The models:
import { Address } from './address.model';
export class Client{
id: number;
name: string;
accountNumber: string;
addressId: number;
phoneNumber: string;
address: Address;
}
export class Address{
id: number;
name: string;
addressLine1: string;
addressLine2: string;
city: string;
postalCode: string;
}
I'm getting the error: Error TS2345 (TS) Argument of type 'Address' is not assignable to parameter of type 'OperatorFunction<{}, Client[]>'.