I am new to angular 2 and currently working with angular 2.2.1, in which I can successfully send a request and get an answer for success, however, when I try to get the Authorization Response header. I always get null, can I get the Content-Type header. Below is my solution for now.
service.ts login method:
login(model: LoginModel) { let requestUrl = '/someurl'; let requestPayload = JSON.stringify(model); let headers = this.getHeaders(false); // ... Set all required headers let options = new RequestOptions({ headers: headers }); // Create a request option return this.http.post(requestUrl, requestPayload, options) // ...using post request //.map((res: Response)) // ...and calling .json() on the response to return data .subscribe((res: Response) => { var payload = res.json(); var authorization = res.headers.get('Authorization'); var contentType = res.headers.get('Content-Type'); console.log(payload, contentType, authorization) }); }
Heading Assistant
getHeaders(isSecureAPI: boolean) { let headers = new Headers({ 'Content-Type': 'application/json', 'Accept': 'application/json' }); if (isSecureAPI) { headers.append('Authorization', 'GetFromSession'); headers.append('X-UserID', 'GetFromSession'); } return headers; }
Fiddler Track:

Angular Console Exit 
So, can anyone guide me, what am I possibly doing wrong?
source share