0

i'm trying to get my access_token using httpclient. However , the response from it is always undefined.

      login(email:string, password:string) {
        var user = 
        {  
          "user": {
              "email": "name@test.com",
              "password": "password",
            }
        };
        return this.httpClient.post<{access_token:  string}>('http://localhost:3000/login', user).pipe(tap(res => {
        localStorage.setItem('access_token', res.access_token);
    }))
    }

edit : this my app component :

export class AppComponent {
  title = 'app works!';
  constructor(private authToken: JwtService){

    this.authToken.login("user11@example.com", "password").subscribe(

        res => {

          console.log('auth response:', res);
        },

        err => {
          console.error('auth error:', err);
        }
    )
  }
}
Tony Ngo
  • 19,166
  • 4
  • 38
  • 60
CHADTO
  • 331
  • 1
  • 4
  • 12

0 Answers0