I am getting this error
Type 'never' must have a 'Symbol.iterator' method that returns an iterator.
I know that error is related to my if statement in the code below (drivers.service.ts)
export class DriversService {
user: User;
comp = '';
constructor(private db: AngularFirestore, private auth: AuthService, private afAuth: AngularFireAuth) { }
getUsers() {
return this.auth.user.pipe(
take(1),
map(user => {
// user['company'];
this.comp = user['company'];
return user['company'];
})
)
}
findUser(value) {
if(this.comp.length <= 0){
return this.getUsers().subscribe(user => {
this.comp = user;
console.log('Bye', this.comp)
return this.comp;
});
}
let email = this.db.collection(`companies/${this.comp}/users`, ref => ref.where('email', '==', value)).valueChanges({ idField: 'id' }).pipe(
take(1)
);
let name = this.db.collection(`companies/${this.comp}/users`, ref => ref.where('name', '==', value)).valueChanges({ idField: 'id' }).pipe(
take(1)
);
return [email, name];
}
And accutal error is showing in add-driver.page.ts in forkJoin()
export class AddDriverPage implements OnInit {
users = [];
participant = '';
form: FormGroup;
constructor(private driverService: DriversService, private loadingCtrl: LoadingController, private auth: AuthService) { }
ngOnInit() {
}
addDriver() {
let obs = this.driverService.findUser(this.participant);
forkJoin(obs).subscribe(res => {
for (let data of res) {
if (data.length > 0) {
this.users.push(data[0]);
}
}
console.log('it works:', this.participant)
this.participant = '';
});
}
}
So how do I solve this issue?