我正在遵循关于使用AngularHTTPInterceptor的教程,但是当我调用handle()方法时,会得到一个错误。
//下一个.handle();
Uncaught TypeError: Cannot read property 'method' of undefined at HttpXhrBackend.push../node_modules/@angular/common/fesm5/http.js.HttpXhrBackend.handle (http://localhost:4200/vendor.js:31148:17) at eval (eval at push../src/app/services/authInterceptor.service.ts.AuthInterceptorService.intercept (http://localhost:4200/main.js:756:9), <anonymous>:1:6) at AuthInterceptorService.push../src/app/services/authInterceptor.service.ts.AuthInterceptorService.intercept (http://localhost:4200/main.js:756:9) at HttpInterceptorHandler.push../node_modules/@angular/common/fesm5/http.js.HttpInterceptorHandler.handle (http://localhost:4200/vendor.js:30859:33) at HttpXsrfInterceptor.push../node_modules/@angular/common/fesm5/http.js.HttpXsrfInterceptor.intercept (http://localhost:4200/vendor.js:31450:25) at HttpInterceptorHandler.push../node_modules/@angular/common/fesm5/http.js.HttpInterceptorHandler.handle (http://localhost:4200/vendor.js:30859:33) at HttpInterceptingHandler.push../node_modules/@angular/common/fesm5/http.js.HttpInterceptingHandler.handle (http://localhost:4200/vendor.js:31494:27) at MergeMapSubscriber.project (http://localhost:4200/vendor.js:30699:184) at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._tryNext (http://localhost:4200/vendor.js:143493:27) at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber._next (http://localhost:4200/vendor.js:143483:18)
import { Injectable } from '@angular/core';
import { HttpInterceptor } from '@angular/common/http';
@Injectable()
export class AuthInterceptorService implements HttpInterceptor{
intercept(req,next){
console.log(req);
return next.handle();
}
}
我做错什么了吗?,因为请求记录正常。
我使用的是角版本7.0.3