I recently developed an authentication service in Angular 5, where I utilize the HttpClient class to make a POST request to my backend server. The backend server then responds with a JWT bearer token.
Here is a snippet of how my request looks:
return this.http.post('http://127.0.0.1:8080/api/v1/login', {
'username': username,
'password': password
}, {
headers: new HttpHeaders()
.set('Content-Type', 'application/json')
})
.toPromise()
.then(response => {
console.log(response);
return response;
});
}
I am having trouble accessing the authorization header from the response object. When I log the response to the console as shown above, it displays 'null'. Interestingly, I have verified that the backend is indeed sending the bearer token by examining the network traffic.
If anyone has any insights or suggestions on how to resolve this issue, please share. Your assistance would be greatly appreciated.