Get response header after post


#1

Hello I am using

@angular/http

for my request, and I want to access the value of header after I request
This is the provider I write:

post(url, parm) {
		return new Promise(resolve => {
			this.http.post(url, parm)
				.map(res => res)
				.subscribe(data => {
					console.log(data)
					resolve(data);
				}, error => {
					error.message = "fail";
					resolve(error);
				});
		});
	}


This is the result but I don’t know how to get the value of "access-token"
can you guild me the ways.


#2

All methods should type their parameters and their return value. Except in extraordinary circumstances, you should not be explicitly instantiating Promises. I consider it a design flaw to initiate and subscribe to an Observable in the same function. map(res => res) is meaningless and should go away. Please post textual data as text, not images. If you can resolve these issues, maybe we can make some more progress.


#3

Never let a great Observable go to waste by subscribing too early or even worse, convert to a promise.

And if you insist on doing so, use the toPromise() operator.