I don't know why i can't get value from header AUTHORIZATION as i see in Postman (return from server).
http://img110.xooimage.com/files/1/6/9/postman-567005e.png
I tried many things but i don't know why i still get a null value.
http://img110.xooimage.com/files/b/c/f/debug-5670075.png
Here is my code:
authentification-service.ts
login(u: User): Observable<HttpResponse<Response>> {
if ((u.username && u.password)) {
this.user.setUsername(u.username);
this.user.setPassword(u.password);
// @ts-ignore
const request = this.http.post<Response>(this.authUrl, this.user, {observe: 'response'} )
.pipe(
tap((data: any) => {
// @ts-ignore
this.log(`Succès ${data.status} authentification succès`, 'success');
this.navigateToCollection();
console.log('data');
console.log(data);
console.log('data.headers.get(Authorization)');
console.log(data.headers.get('Authorization'));
return localStorage.setItem(TOKEN_KEY, data.headers.get('Authorization'));
}),
catchError(this.handleError<any>('login',
console.log('je passe ici3')))
);
request.subscribe(value => {
// console.log(value.headers.get('Authorization'));
console.log(localStorage.getItem(TOKEN_KEY));
});
this.presentLoading(request);
console.log('je passe ici4');
return request;
} else {
this.log('Renseignez les champs', 'error');
alert('Erreur de login ou de mot de passe');
}
}
My token is send by my service authentification (spring boot) if you need more informations ask me.
I would like to know how to get this header value.
thank you for your time.