How do I access the HEADERS
data in Angular 2?
My NGINX server sends the HEADERS
object you see below. I have used Express so far and I could get the data very easily, but I have been trying to do so on Angular 2 with no luck. My app requires the header body to perform other operations.
NOTE User -> Nginx ( Sends Header ) -> Angular2 ?!?! how to read it
STATUS: 200
HEADERS: {"server":"nginx","date":"Thu, 02 Mar 2017 06:31:17 GMT","content-type":"application/json; charset=utf-8","transfer-encoding":"chunked","connection":"close","vary":"Accept-Encoding, Accept-Encoding",.... and so on
BODY: {"other stuf .... "}
You can use this library it adds the interceptor feature to Angular 2, by extending the @angular/http class.
Although you can write your own class extending the http class but that would take time and since angular2 doesn not provide any intercepting capabilities you are better off this library.