0

Here is my code:

$http({
         method: 'POST',
         url: myURL,
         headers: {
           //BLAH
         },
         data: {
           // BLAH BLAH
         }
     }).success(function(data, status, headers) {
         deferred.resolve({
         // This is not possible:
         sessionId: headers('sessionId')
        });
   });

I would like to access sessionId attribute from headers, but only header I seem to find is Content-Type.

What may be the cause why this does not work?

1 Answer 1

2

I found this post useful: https://github.com/mgonto/restangular/issues/128

It states the following:

After research I found the solution: you have to tell your api server to "expose" the custom headers. You can do this by using the Access-Control-Expose-Headers header. The value is the headers you want to be able to access. So it'd look like: Access-Control-Expose-Headers: Your-Header, Another-Header.

Adding this extra header solved my problem.

Sign up to request clarification or add additional context in comments.

1 Comment

Another visible layer without this setting is according to the source Cache-Control.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.