Hello!
I'm implementing a login method. When the user logs in, the backend generates a JWT and sends the token to be stored in the localStorage of the HTML.
Never used TS / Angular 4, in AngularJS I had no problem with this, see my function, can you tell me why it is not working? The console.log("response: ", response.body.token)
is returning null.
login() {
this.auth.authenticate(this.creds)
.subscribe(response => {
console.log("response: ", response.body.token)
this.auth.successfulLogin(response.headers.get('Authorization'))
this.navCtrl.setRoot('DetalhesViagemPage')
},
error => {})
}
Return from console.log("response: ", response.body)
:
response: {"nome":"Frederico","_id":"5b21a4332a5e3333cc64a12f","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyIkX18iOnsic3RyaWN0TW9kZSI6dHJ1ZSwic2VsZWN0"}