I got this JSON error when getting token in Angular

41 Views Asked by At

I have this header x-token added

postman config

I set my token saved in localStorage by using headers in Angular service:

validateToken(){
    let headers = new HttpHeaders().set('x-token', localStorage.getItem('token') || '');
    return this.authService.get("/api/auth/relogin",{headers})
}

I subscribe info in other component:

login(){
    this.authService.validateToken().subscribe(token => console.log(token));
}

What i got is this error:

error in console

I've tried to do configs in the request, i've seen solutions like adding responseType:'text' and more like that, but when doing it, the subscribe info shows this in console:

console log info when adding responseType:'text'

0

There are 0 best solutions below