I make a post request to a server which responds with two headers that are important for the client: username and access-token.
The Network Tab of the Chrome debug tool displays the following data for the response:
I also log the response on the console:
Here the headers are not present - why is this? My code for logging:
this.usersService.registerNewUser(firstName, lastName, email, username, birthday, password).subscribe(
res => {
console.log(res);
},
err => {
console.log("Error" + JSON.stringify(err));
}
);
I wanted to access the header username by res.headers.username
.
My request looks like this:
this.http.post<string>(
"http://localhost:2002/users",
JSON.stringify({
firstName: firstName,
lastName: lastName,
email: email,
username: username,
birthday: birthday,
password: password
}),
{
observe: "response"
}
);
What have I done wrong?