4

I am getting the following error

Argument of type '(user: User) => void' is not assignable to parameter of type '(value: User, index: number) => ObservableInput'. Type 'void' is not assignable to type 'ObservableInput'.

 getCurrentUserDb()
  {
    return this.login.authState.pipe(
                        switchMap(user=>{
                          return this.serviceUsers.getUserByuid(user.uid);
                        }),
                        map(user=>{
                          return user;
                        })
    )
  }
user13321892
  • 49
  • 1
  • 5

2 Answers2

7

I believe you were trying to map the results from the inner observable (map(user => ...) but instead applied it to the source. If so, try the following

getCurrentUserDb(): Observable<any> {
  return this.login.authState.pipe(
    switchMap(user => {
      return this.serviceUsers.getUserByuid(user.uid).pipe(
        map(user => {
          return user;
        })
      );
    })
  );
}
ruth
  • 29,535
  • 4
  • 30
  • 57
1

Is this.serviceUsers.getUserByuid(user.uid) returning an Observable? It looks like you're trying to switchMap to a void.

ggradnig
  • 13,119
  • 2
  • 37
  • 61