switchMap does not exist on type Observable in Angular

Asked on November 17, 2018
I have an Angular demo project which I have created using Angular 4. Now I updated to Angular 7. But it is not running and throwing error
"switchmap does not exist on type observable"
How to resolve it?

Replied on November 17, 2018
Angular 6 integrates RxJS 6 and importing RxJS operators has changed.
import { Observable, of } from 'rxjs';
import { mergeMap, switchMap, retry,
map, catchError, filter, scan } from 'rxjs/operators';
RxJS operators are used within <code>pipe</code> instance method of Observable.
Find the sample code.
this.bookService.getFavBookFromStore(id).pipe(
switchMap(book => {
let category = book.category;
return this.bookService.getBooksByCategoryFromStore(category);
}),
catchError(err => of([]))
)
.subscribe(books => {
this.similarBooks = books;
console.log(books);
});