Angular: 为什么 $http GET 参数加密?
Angular: why $http GET params encrypted?
我有一个 GET
方法,但由于某种原因它发送加密 params
var request = function (apiMethod, apiResponse) {
var deferred = $q.defer();
var apiPath = getApiPath();
apiPath = $rootScope.ROOT_URL + apiPath;
var config = {
method: 'GET',
url: apiPath + apiMethod,
params: 'email=myemail@gmail.com, timestamp_start=1432801800, timestamp_end=1432803600, organizer_email= myemail@gmail.com, cloudinary_rules=scale, meeting_name=123',
//data: apiResponse,
//headers: {'Content-Type': 'application/x-www-form-urlencoded'},
//withCredentials: true,
timeout: canceler.promise
};
$http.get(config).success(function (data) {
$rootScope.showLoader = false;
if (data.message === undefined) {
deferred.resolve(data);
} else {
deferred.reject(data);
}
}).error(function (data, status, headers, config) {
$rootScope.showLoader = false;
deferred.reject(data);
});
return deferred.promise;
};
但是我收到的请求是:
如何发送正确的 GET 请求?
你应该试着给他一个对象而不是字符串:
var config = {
method: 'GET',
url: apiPath + apiMethod,
params: {
email:"myemail@gmail.com",
timestamp_start:1432801800,
timestamp_end:1432803600,
[etc...]
}
//data: apiResponse,
//headers: {'Content-Type': 'application/x-www-form-urlencoded'},
//withCredentials: true,
timeout: canceler.promise
};
它可能试图 URL 将整个字符串编码为一个参数但不确定。
希望对您有所帮助。
编辑:哈哈,重新阅读获取请求。
其实就是把字符串当做参数数组。所以它将每个字母作为一个参数发送(查看参数顺序:0:e - 1:m - 2:a(ema ...)[etc ...]。
我有一个 GET
方法,但由于某种原因它发送加密 params
var request = function (apiMethod, apiResponse) {
var deferred = $q.defer();
var apiPath = getApiPath();
apiPath = $rootScope.ROOT_URL + apiPath;
var config = {
method: 'GET',
url: apiPath + apiMethod,
params: 'email=myemail@gmail.com, timestamp_start=1432801800, timestamp_end=1432803600, organizer_email= myemail@gmail.com, cloudinary_rules=scale, meeting_name=123',
//data: apiResponse,
//headers: {'Content-Type': 'application/x-www-form-urlencoded'},
//withCredentials: true,
timeout: canceler.promise
};
$http.get(config).success(function (data) {
$rootScope.showLoader = false;
if (data.message === undefined) {
deferred.resolve(data);
} else {
deferred.reject(data);
}
}).error(function (data, status, headers, config) {
$rootScope.showLoader = false;
deferred.reject(data);
});
return deferred.promise;
};
但是我收到的请求是:
如何发送正确的 GET 请求?
你应该试着给他一个对象而不是字符串:
var config = {
method: 'GET',
url: apiPath + apiMethod,
params: {
email:"myemail@gmail.com",
timestamp_start:1432801800,
timestamp_end:1432803600,
[etc...]
}
//data: apiResponse,
//headers: {'Content-Type': 'application/x-www-form-urlencoded'},
//withCredentials: true,
timeout: canceler.promise
};
它可能试图 URL 将整个字符串编码为一个参数但不确定。
希望对您有所帮助。
编辑:哈哈,重新阅读获取请求。
其实就是把字符串当做参数数组。所以它将每个字母作为一个参数发送(查看参数顺序:0:e - 1:m - 2:a(ema ...)[etc ...]。