0

I am working on an Progressive Web app module with AngularJS.

I have made a network call with POST request using '$http', I am able to get a response of it but am not getting 'Response Header' params.

Here is my Response header:

Connection:keep-alive
Content-Type:application/json
Date:Fri, 19 May 2017 10:41:49 GMT
Server:JBoss-EAP/7
Session-ID:XXXXX-YYYY-ZZZ
Transfer-Encoding:chunked
X-Powered-By:Undertow/1

And below is a request and API call.

$scope.data = {userid: $scope.username,
            os: 'android',
            device_id: 'b0316b93ae786ec0',
            source: 'iv2',
            password: $scope.password,
            build_version_code: '2.3',
            version: '5.1.1'};

            $http({
                method : "POST",
                url: 'https://domain.name/v1/users/login',
                data : $scope.data,
                headers: {
                    'content-type': "application/json",
                    'sessionID': ''
                }

            })
            .then(function successcallback(response){
                console.log("Session-ID" , response.headers());
                console.log("response" , response);
            }, function errorcallback(response){
                console.log('error' , response);
            });

I have tried below possible solution based on response callback method.

function successcallback(response){
  response.header('Session-ID');
}

and 

success(function(response , status , headers , config){
    console.log("response" ," headers - " + headers('Session-ID'));
}

The both approaches returns a null value instead of expected value. Please let me know if I am missing something. I am happy to get all possible help.

Neo
  • 260
  • 2
  • 14
  • Possible duplicate http://stackoverflow.com/questions/28805589/how-to-read-response-headers-in-angularjs – Agam Banga May 19 '17 at 11:21
  • HI. Thanks for the reply. I have tried this solution, but again the same response I am getting. – Neo May 19 '17 at 12:27

0 Answers0