Angular 6 ERROR TypeError:无效的调用对象

时间:2018-09-30 07:20:08

标签: angular

答案:该错误与Angular无关,但与一个名为speed的库有关。它以某种方式中断了http客户端。

我有一个可以在Chrome中正常运行的应用程序,但在IE和Edge中却无法正常运行。当我尝试致电服务时会发生这种情况:

Service:
getTest():Observable<string[]>{
  var url = `https://xx.azurewebsites.net/api/test`;
  return  this.httpClient.get<string[]>(url);    
}

组件调用服务:

callApi(){
   console.log('ddddddddd');
   this.apiService.getTest().subscribe((data) => {
     console.log('ddddddddd');
     this.test  =  data;
     console.log(this.test);
   });
}

Auth-interceptor:

import { Injectable } from '@angular/core';
import { HttpEvent,HttpHandler,HttpRequest,HttpInterceptor } from '@angular/common/http';
import { AdalService } from 'adal-angular4';
import { Observable } from 'rxjs';

@Injectable()
export class AuthInterceptor implements HttpInterceptor {
    constructor(private adalService: AdalService) { }

    intercept(req: HttpRequest<any>, next:HttpHandler): Observable<HttpEvent<any>>{
        const authHeader = this.adalService.userInfo.token;
        var header = 'Bearer ' + authHeader;
        const authReq = req.clone({headers: req.headers.set('Authorization', header)});
        return next.handle(authReq);
    }

}

任何想法会导致这种情况吗?

enter image description here

调试器: enter image description here

1 个答案:

答案 0 :(得分:0)

答案:该错误与Angular无关,但与一个名为speed的库有关。它以某种方式中断了http客户端。