Hey there,
I am receiving the following error:
Model ts file:
export interface AvailableRoom {
BedNo: string;
CreatedAt: string;
Message: string;
Name: string;
NotificationId: string;
Title: string;
}
export interface Notification {
BedNo: string;
CreatedAt: string;
Message: string;
Name: string;
NotificationId: string;
Title: string;
}
I am trying to retrieve the following filtered data by passing the following id from the paramMap in the service file when after routing.
Notification-details ts page:
export class NotificationDetailPage implements OnInit {
Notification: Notification[];
constructor(private activatedRoute: ActivatedRoute, private retrievedata: RetrieveDataService ) { }
ngOnInit() {
this.activatedRoute.paramMap.subscribe(paramMap => {
if(!paramMap.has('roomid')){
return;
}
const roomid = paramMap.get('roomid');
this.Notification = this.retrievedata.GetRoomId(roomid);
console.log(this.Notification);
});
}
My service ts file:
JWTToken: string;
httpHeaders: HttpHeaders;
Availableroom: AvailableRoom[];
Notification: Notification[];
AddedNotification: Notification[];
GetPatientBedNo(){
Auth.currentAuthenticatedUser().then(user => {
this.JWTToken = user.signInUserSession.accessToken.jwtToken;
this.httpHeaders = new HttpHeaders({
Authorization: this.JWTToken
});
this.http.get<any>('https://2nkjq83td2.execute-api.ap-southeast-1.amazonaws.com/support/notifications', {headers: this.httpHeaders}).subscribe(data => {
data.sort((a,b) => {
if(a.CreatedAt < b.CreatedAt){
return 1;
} else {
return -1;
}
}
);
this.Notification = data;
var tempBedNo = []
this.Availableroom = data.filter(item => {
if (!tempBedNo.includes(item.BedNo)) {
tempBedNo.push(item.BedNo);
return true;
}
else {
return false;
}
})
})
});
}
GetRoomId(roomid: string){
{
return [...this.Notification.filter(notification => {
return notification.BedNo == roomid;
})];
}
}
}