HTTPエラーをよりうまく処理できるようにこのHTTPInterceptorを作成しましたが、git pullを実行してnpmをインストールする前にうまくいきました。角4 HTTPインターセプター:next.handle(...)。doは関数ではありません
これは私のコードです:
import {Injectable} from '@angular/core';
import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpResponse} from '@angular/common/http';
import {Observable} from "rxjs";
import {ToasterService} from "angular2-toaster";
@Injectable()
export class GobaeInterceptor implements HttpInterceptor {
constructor(private toasterService: ToasterService){
}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(req)
.do(event => {
if (event instanceof HttpResponse) {
let response = event.body;
if(response.Error){
this.toasterService.pop('error', 'Error '+response.Code, response.Message);
}
}
});
}
}
そして、これは私が取得エラーです:
TypeError: next.handle(...).do is not a function at GobaeInterceptor.webpackJsonp.../../../../../src/app/services/gobae.interceptor.ts.GobaeInterceptor.intercept (gobae.interceptor.ts:12) at HttpInterceptorHandler.webpackJsonp.../../../common/@angular/common/http.es5.js.HttpInterceptorHandler.handle (
は私のコードが最近変更影響を与える可能性が何かをしましたか?私のインターセプタでhttpレスポンスを「捕まえる」ために今私は何ができるでしょうか?
一体迎撃のためのプロバイダは、まだそこにちょうどプルの前と後のコードの比較または何のファイルどこプル後に変更ない方が良い場合。私はモジュールプロバイダがないと思います。またはさらにhttpclientmodule –