I am getting this error. I'm trying to use
import { catchError } from 'rxjs/operators'
instead of
import 'rxjs/add/operator/catch'
But what to use instaed of rxjs/add/operator/do and rxjs/add/operator/toPromise?
The import statements depend on the RxJS version.
RxJS 5+
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/toPromise';
RxJS 6+
import { catchError, tap } from 'rxjs/operator';
The catch and do operators were replaced with catchError and tap respectively. Nothing has to be imported for toPromise since it isn't pipeable and invoked directly on an observable.
Also, if you're using toPromise you need to know that it is being deprecated in RxJS 7 and will be gone in RxJS 8.
lastValueFrom or firstValueFrom instead. However I'd tell you to refrain converting observables to promises unless there is an explicit need for it. Observables in general also provide more control over the stream of data.