AngularJS: Response header returns empty object

I am using AngelsJS $ http post response response to manage the location parameter. When I check my browser; it shows that a response header containing a location parameter with a value, but when it comes to the AngularJS response header object, it is a docent containing anything at all other than an empty object.

$http.post(MNS_DOMAIN + SERVER.MESSAGE_PROXY, JSON.stringify(payload))
                .success(function(data, status, headers, config) {
            $scope.messageLocation = headers();

            $scope.success = SUCESS_DATA_SENT;
            clearFormData();
        })
                .error(function(errorCallback) {
            $scope.error = errorCallback;
            console.log("Error " + errorCallback);
        })
                . finally(function() {
            console.log("REST call for send message");
        });

        console.log($scope.error);
    };

      

+3


source to share


1 answer


I did it using headers - {function ([headerName])} - Header getter function.

You can do something like this:



var headerObject = data.headers();

and access the properties like headerObject["propertyName"] to get the value.

      

$ http

0


source







All Articles