如何使用 lettable 运算符和管道执行以下操作?
this.httpClient
.get(url)
.map((res: any) => {
const events = res.eventList;
return events.map(e => new EventLogModel(e));
})
.catch(this.handleError);
我已经尝试过了,但我无法开始catchError
工作: catchError does not exist on type Observable<any>
:
this.httpClient
.get(url)
.pipe(
map((res: any) => {
const events = res.eventList;
return events.map(e => new EventLogModel(e));
})
)
.catchError(this.handleError);
另外,我假设catch
并且catchError
是相同的,对吗?我像这样导入它:
import { map, catchError } from 'rxjs/operators';
但我不确定这是否是正确的运算符。