Property 'switchMap' does not exist on type 'Observable<User>'
You should be importing from rxjs/add/operator/switchMap
if you're using the older "patch" style of operators:
import 'rxjs/add/operator/switchMap';
Since RxJS 5.5 with "pipable" operators you should import from 'rxjs/operators'
:
import { switchMap } from 'rxjs/operators';
I assume you're using Angular 6, which mean you're using the latest version of RxJS. You need to pipe your operators as
obs$.switchMap(() => { do stuff... });
change to
obs$.pipe(switchMap(() => { do stuff... }));
Edit: keep in mind that in your case, your observable is returned by this.refreshToken
this.refreshToken().pipe(switchMap(() => { do stuff... }));
I think If you are using Angular 6 then you should use pipe
Version less than angular 6, the below code will works
this.route.params.switchMap((data: Passengers) =>
this.passengerService.getPassenger(data.id))
.subscribe((data: Passengers) => this.passenger = data);
But for In Angular 6, you should pipe your operators
this.route.params.pipe(switchMap((data: Passengers) =>
this.passengerService.getPassenger(data.id)))
.subscribe((data: Passengers) => this.passenger = data);