[英]Intercepting errors in Angular2 - issue with catch
I was following this answer by Thierry Templier
, but run into some troubles when defining error interceptors ( other interceptors are working ). 我遵循Thierry Templier
回答 ,但是在定义错误拦截器时遇到了一些麻烦( 其他拦截器正在工作 )。
I have the following: 我有以下几点:
get(url: string, options?: RequestOptionsArgs): Observable<Response> {
console.log('get...');
return super.get(url, options).catch(res => {
this.router.navigate(['Login']);
return Observable.of(res)
});
}
Which throws : 哪个抛出:
vendor.min.js:38333 ORIGINAL EXCEPTION: TypeError: _super.prototype.get.call(...).catch is not a function vendor.min.js:38333原始异常:TypeError:_super.prototype.get.call(...)。catch不是函数
Any ideas? 有任何想法吗?
我认为您可能忘记了在定义拦截器类的模块中导入catch
操作符:
import 'rxjs/add/operator/catch';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.