Currently, I'm in the process of writing an API GET request by utilizing HttpClient.get()
. Upon passing in the option to observe the response, I've encountered an issue where accessing the .keys()
does not provide me with any headers apart from Content-Type
.
Even though the Access-Control-Allow-Origin
header has been set as a wild card (*), I am still limited to only being able to access the Content-Type
header within Angular. What could be the missing piece of the puzzle here?
In my networking tab, it's clear that the header is correctly sent to my browser. Furthermore, I attempted explicitly allowing that custom header in the Access-Control-Allow-Origin
settings.
Here's a snippet of my Angular App:
this.data.getClubs(1, 10, '', {clubName: 'asc'}, '').subscribe(
dataJson => {
console.log(dataJson.headers.keys());
}
getClubs(page: number, count: number, group: any, sorting: any, filter: any) {
return this.http.get(this.apiUrl + `/club`, {
params: {
count: String(count),
filter: String(filter),
group: String(group),
page: String(page),
sorting: JSON.stringify(sorting)
},
headers: this.getHttpOptions().headers,
observe: 'response'
});
}
Please take a look at these images showcasing that the header is indeed configured to allow access: https://i.sstatic.net/Q6sk6.png https://i.sstatic.net/hAVHV.png
Your assistance on resolving this matter would be greatly appreciated!