I am in need of assistance as I am struggling to retrieve the cookie from the response. Being new to tsc and ng2, I can't seem to find a solution.
Below is the ng2 http post method:
return this._http
.post('http://demo...', body, { headers: headers })
.subscribe(
(response: Response) => {
this.storeToken(response);
}, (err) => {
console.log('Error: ' + err);
}
);
This is the server's response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Access-Control-Allow-Origin: http://localhost:3000
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With
Set-Cookie: JSESSIONID=A099CC4CA7A25DFBD12701630A7DC24C; Path=/pbcp/; HttpOnly
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Fri, 17 Feb 2017 04:08:15 GMT
32
{"status":"OK","message":"User is Authenticated."}
0
I'm puzzled because I can't locate it within the headers array...
Result of console.log(response)
https://i.sstatic.net/hPu2U.png
Result of console.log(response.headers)
https://i.sstatic.net/hPu2U.png
...however, it appears in the cookies section.
https://i.sstatic.net/hPu2U.png
Your help is greatly appreciated!