Я пытаюсь получить свой access_token, используя httpclient.Однако ответ от него всегда не определен.
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: этот компонент моего приложения:
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);
}
)
}
}