I am trying to get the data from the service in to the component below is my service
Service.ts
export class PrjService {
tDate: Observable<filModel[]>;
prjData:Observable<filModel[]>;
entityUrl;
constructor(){
this.entityUrl = 'PrjDetail/GetByRep';
this.tDate = service.get<ShipDateFilterModel[]>(this.entityUrl);
}
And the component where I try to retrieve is like below
export class RFComponent implements OnInit {
cachedResults: any[];
shipToData: any;
constructor(private psService: PrjService)
{}
ngOnInit() {
this.psService.tDate.subscribe(x => this.cachedResults = x);
this.filterData = [...new Set(this.cachedResults.map(item => item.cus_name))].filter(Boolean);
}
Here whenever the Call to the service is made this.cachedResults
is undefined and I get the error in the below like where I am trying to filter
ERROR TypeError: Cannot read property 'map' of undefined
Not sure what I am missing here