我有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请求?
答案 0 :(得分:3)
你应该尝试给他一个对象而不是一个字符串:
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 ...]。