I am currently working with an external API and angular 5. The current issue is when I make a request to the backend with correct credentials I receive a response with an authorization header but angular says that the header does not exist. Here is some small code snipits
return this.http.post<any>(this.apiUrl + "/api/login", farmer, { observe: 'response' }).pipe(
map(response => {
localStorage.setItem("token", response.headers.get('Authorization'))
return response.headers.get('Authorization');
})
)
Above is my api service call ^
Below is my component call:
onSubmit() {
if (this.loginForm.valid) {
this.restApiService.apiLogin(this.loginForm.value).subscribe(response => {
console.log(response);
// const keys = response.headers.get('Authorization');
// console.log("Header Keys", keys)
});
}
}
From these two snippits I get the output of Null and the token in local storage is null. This could be an overwrite issue but i have also just checked response.headers.get('Authorization');
and it is null. Let me know if i need to post more.