How to access headers from a HttpClient response? (Angular / Ionic)

后端 未结 3 791
面向向阳花
面向向阳花 2020-12-19 13:36

I\'m using a login endpoint that returns a bearer token as a response header, as I can see in the \"Network\" Chrome inspect window:

Response Headers
Access-         


        
3条回答
  •  误落风尘
    2020-12-19 14:31

    Are you sure you are adding it as a part of the response? You need to add the header in the response:

    public void methodJava(HttpServletResponse response){
      ...
     response.addHeader("access-control-expose-headers", "Authorization");
    }
    

    And then you can do what you have been trying. I think headers.get('Authorization') should give you the desired value

提交回复
热议问题