提问者:小点点

Angular 7 http帖子中未定义的“toLowerCase”


看了几个论坛,好像找不到这个问题。

我有一个身份验证服务,应该使用令牌进行响应。

这是我的身份验证服务呼叫。

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';

@Injectable()
export class AuthService {
    baseUrl: 'https://api.website.com/login/';

    constructor(private http: HttpClient) { }

    login(model: any) {
        return this.http.post(this.baseUrl, model)
            .pipe(
                map(data => data)
            );
    }
}

在我的登录组件中,我有以下调用:

login() {
    this.auth.login(this.model)
      .subscribe(
        (data: any) => {
          console.log(data);
        },
        (error: any) => {
          console.log(error);
        }
      );
  }

我在控制台收到以下错误-

TypeError: 无法读取 HttpXsrfInterceptor.push 上未定义的属性 'toLowerCase'。/node_modules/@angular/common/fesm5/http.js.HttpXsrfInterceptor.intercept (http.js:1719) at HttpInterceptorHandler.push../node_modules/@angular/common/fesm5/http.js.HttpInterceptorHandler.handle (http.js:1135) at HttpInterceptingHandler.push../node_modules/@angular/common/fesm5/http.js.HttpInterceptingHandler.handle (http.js:1770) at MergeMapSubscriber.project (http.js:975) at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators /mergeMap.js.MergeMapSubscriber._tryNext (mergeMap.js:61) at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators /mergeMap.js.MergeMapSubscriber._next (mergeMap.js:51) at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54) at Observable._subscribe (scalar.js:5) at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe (Observable.js:43) at Observable.push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe (Observable.js:29)

我没有任何拦截器,也不确定这些都是从哪里来的。有帮助吗?


共1个答案

匿名用户

变化

 baseUrl: 'https://api.website.com/login/';

 baseUrl= 'https://api.website.com/login/';