Reading response headers when using $ http Angularjs

I use $http to make an api call that sends some custom header like X-Foo . However, I still cannot figure out how to read them. Inside the function $http({...}).success(function (data, status, headers, config) {...}) headers is a function that should give me a hash of all the headers, but only show the content-type header . Is there any way to get response headers?

+61
angularjs
Jun 11 '13 at 7:14
source share
2 answers

Custom headers will be visible in the same domain. However, for a cross-domain situation, the server must send an Access-Control-Expose-Headers: X-Foo, ... header to make custom headers visible.

+143
Aug 12 '13 at 1:50
source

Spring 4.0+ provide the @CrossOrigin annotation, which has the following parameters

  • originins = comma separated list of origin.
  • protectedHeaders = list of user parameters count count associated with the lump.

example

 @CrossOrigin(origins = "*", exposedHeaders ="X-Total-Count") 
0
Aug 10 '17 at 7:27
source



All Articles