小编Moh*_*hid的帖子

Angular 12 TypeError:无法在 HttpHeaders.applyUpdate 读取 null 属性(读取“长度”)

当我在 Angular 服务中发出 http 请求时,收到此错误消息。仅当我注销时才会发生这种情况,但当我登录时错误就会消失:

这是我的身份验证服务:

import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError, retry, map } from 'rxjs/operators';
import { JwtHelperService } from '@auth0/angular-jwt';

export interface ServerResponse {
  success: boolean;
  msg: string;
  user: any;
  token: any
}

@Injectable({
  providedIn: 'root'
})

export class AuthService {

    authToken: any;
  user: any;
    public baseUri: string = 'http://localhost:3000/users';
    public headers = new HttpHeaders().set('Content-Type', 'application/json')

  constructor(private http: HttpClient) { …
Run Code Online (Sandbox Code Playgroud)

http httpclient rxjs typescript angular

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×1

http ×1

httpclient ×1

rxjs ×1

typescript ×1