AngularJS - $ http错过了请求Payload中的特定密钥

时间:2017-03-07 16:56:32

标签: javascript angularjs http request payload

我正在使用1.5.7角,并且不知道为什么它丢失了那把钥匙。该错误的频率非常低。

服务器端很少在没有“priceMin”的情况下获得发布请求有效负载:

预期:

{priceMin: 0, priceMax: 964, category: "", name: ""}

我得到了什么:

{priceMax: 964, category: "", name: ""}

function _doRequestPOST(request_url, data) {
        var def = $q.defer(),
            request = {
                headers: {
                    'X-Requested-With' :'XMLHttpRequest'
                },
                method  : 'POST',
                url     : request_url,
                data    : data
            };

        http = $http(request).then(
            function(response){
                //success
                def.resolve(response);
            },
            function(response){
                //error
                def.reject(response);
            }
        );
        delete http;
        return def.promise;
    };

this.sendStats = function(){
        var requestData = {
                priceMin: self.priceRange.min,
                priceMax: self.priceRange.max,
                category: self.filterExterior,
                name: self.searchBot.name
            };
        _doRequestPOST('/saveFilterData', requestData);
        }
    };

0 个答案:

没有答案