Answer the question
In order to leave comments, you need to log in
How to read Cookies in back response in Angular 4?
From the front to Angular 4 I make a request to the backend, they receive Respons with a cookie.
The code:
login(somevar: string, somevartwo: string) {
return this.http.post('http://somebackand.com/login',
{username: username, password: password},
{
observe: "response",
headers: new HttpHeaders({
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
"Access-Control-Allow-Headers": "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token,Access-Control-Allow-Origin, Authorization, Access-Control-Allow-Origin",
"crossDomain": "true",
"Access-Control-Allow-Credentials": "true"
})
})
.map(response => {
console.log(response.headers.get("Set-Cookie"));
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question