I try to get data using Subscription but it return error Type 'Subscription' is missing the following properties from type 'BehaviorSubject<CalendarEvent<{ book: Book; }>[]>'. The error come from this part this.events$ =
I arrange code like this.
auth.service
getSeating() {
return this.http.get<any>(environment.apiBaseUrl+environment.path+`/data/getseating`)
.pipe(
tap(res => this.setSession),
shareReplay()
);
}
commonce.service
_getSeating(){
this.loading.present();
this.auth.getSeating()
.pipe(take(1))
.subscribe(
res => {
// console.log(res)
if (res['status'].code == 0) {
this.bookSeatList$.next(res['seating']);
}else {
this.toastMsg(res['status'].message);
}
this.loading.dismiss();
},
error => {
this.loading.dismiss();
}
)
}
in my component page I arrange like this
events$: BehaviorSubject<CalendarEvent<{ book: Book }>[]>;
ngOnInit() {
this.fetchEvents();
}
fetchEvents() {
const getStart: any = {
month: startOfMonth,
week: startOfWeek,
day: startOfDay,
}[this.view];
const getEnd: any = {
month: endOfMonth,
week: endOfWeek,
day: endOfDay,
}[this.view];
this.events$ = this.commonService.bookSeatList$.subscribe(res=>{
console.log(res);
return res.map((book: Book) => {
console.log(book);
return {
title: book.earlyBird,
start: new Date(
book.date + getTimezoneOffsetString(this.viewDate)
),
color: colors.yellow,
allDay: true,
};
});
})
}
value from this.bookSeatList$.next(res['seating']);
`
0: {date: "2021-04-14", earlyBird: 100, standard: 130}
1: {date: "2021-04-15", earlyBird: 100, standard: 130}
2: {date: "2021-05-11", earlyBird: 0, standard: 200}
3: {date: "2021-05-12", earlyBird: 0, standard: 200}
4: {date: "2021-04-16", earlyBird: 98, standard: 130}
5: {date: "2021-04-17", earlyBird: 94, standard: 130}
6: {date: "2021-04-19", earlyBird: 99, standard: 130}
7: {date: "2021-04-18", earlyBird: 100, standard: 130}
8: {date: "2021-04-20", earlyBird: 100, standard: 130}
9: {date: "2021-04-21", earlyBird: 0, standard: 200}
10: {date: "2021-04-23", earlyBird: 0, standard: 200}
11: {date: "2021-04-22", earlyBird: 0, standard: 200}
12: {date: "2021-04-24", earlyBird: 0, standard: 200}
13: {date: "2021-04-25", earlyBird: 0, standard: 200}
14: {date: "2021-04-26", earlyBird: 0, standard: 200}
15: {date: "2021-04-27", earlyBird: 0, standard: 200}
16: {date: "2021-04-28", earlyBird: 0, standard: 200}
17: {date: "2021-04-29", earlyBird: 0, standard: 200}
18: {date: "2021-04-30", earlyBird: 0, standard: 200}
19: {date: "2021-05-02", earlyBird: 0, standard: 200}
20: {date: "2021-05-01", earlyBird: 0, standard: 200}
21: {date: "2021-05-03", earlyBird: 0, standard: 200}
22: {date: "2021-05-04", earlyBird: 0, standard: 200}
23: {date: "2021-05-05", earlyBird: 0, standard: 200}
24: {date: "2021-05-06", earlyBird: 0, standard: 200}
25: {date: "2021-05-07", earlyBird: 0, standard: 200}
26: {date: "2021-05-08", earlyBird: 0, standard: 200}
27: {date: "2021-05-09", earlyBird: 0, standard: 200}
28: {date: "2021-05-10", earlyBird: 0, standard: 200}
length: 29
__proto__: Array(0)