当我在 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)