Type 'void' is not assignable to type 'ObservableInput<any>'

Viewed 5452

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;
                        })
    )
  }
2 Answers

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;
        })
      );
    })
  );
}

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

Related