I have an Array that is built within a subscription. Now I want to use the array to find a string in it. I tried .include() and .find(). Both return always false, even if the string is there.
Is this normal behavior and is there any workaround to at least iterate through it?
//array initialization in beginning
seatsReserved = new Array<String>();
//pushing data to the Array
this.dataService.getBookings().subscribe(res => {
res.forEach(booking => {
if(booking.Event_ID === this.eventId){
this.seatsReserved.push(...booking.seats.split(","));
}
})
})
//Method that gets called
getBookings(): Observable<Bookings[]> {
const eventsRef = collection(this.firstore, 'Bookings');
return collectionData(eventsRef, { idField: 'id'}) as Observable<Bookings[]>
Console.Log(this.seatsReserved)
shows the Array the following:
The brackets at Array[]
are empty, the length seems to be 0.