我试着去的$ HTTP REST GET呼叫我Appgyver项目工作的工作,但我没有这样做,似乎来的权利,总是会返回一个错误。
请注意,角应用程序将在移动设备最终被运行,然后连接到我的远程Web服务。
我仔细检查过我的自定义API工作,并在许多方面,即正确地返回数据:
- 硬编码从终端SH文件上运行cUrl作者请求 - 返回数据和正确200码
- 经测试,在这两个邮递员,Firefox的SOA客户端API终点。
把在我的测试终点http://somesite.com/quote-and-buy-performance/druidapi/taxonomy_term如下返回数据:
[{"tid":"1","vid":"2","name":"ACME Ltd.","description":"","format":"filtered_html","weight":"0","parent":"0","uri":"http://somesite.com/quote-and-buy-performance/druidapi/taxonomy_term/1"},{"tid":"2","vid":"2","name":"ABC Films LTD","description":"","format":"filtered_html","weight":"0","parent":"0","uri":"http://somesite.com/quote-and-buy-performance/druidapi/taxonomy_term/2"}]
即使是一个简单的CSRF令牌请求给我的错误。
可能有人可能指出哪里我在这里会错了,Appgyver部位被严重记录,我已经试过这我下面的代码是从基于REST风格的角度样品https://docs.angularjs.org/api/ng/service/ $ http和https://docs.angularjs.org/api/ng/service/ $ HTTP设置#-HTTP报头
请注意下面的代码基本上是Angular.js使用JavaScript语法(而不是CoffeeScript的),日志输出如下的代码
angular
.module('main')
.controller('LoginController', function($scope, supersonic, $http) {
$scope.navbarTitle = "Settings";
$scope.stoken = "Response goes here";
$scope.processLogin = function(){
var csrfToken;
steroids.logger.log("START CALL: processLogin");
// $form_login_email_address = $scope.login_email;
// $form_login_password = $scope.login_password;
$local_get = "http://somesite.com/quote-and-buy-performance/services/session/token";
$hal_get_taxterm_index = "http://somesite.com/quote-and-buy-performance/druidapi/taxonomy_term";
// $http.defaults.headers.common.contentType('application/json');
var req = {
method: 'GET',
url: $hal_get_taxterm_index,
headers: {
'Content-Type': 'application/json'
}
}
$http(req)
.success(function(data, status, headers) {
steroids.logger.log("Inside http.get() success");
}).error(function(data, status, headers){
steroids.logger.log("Inside http.get() WITH ERROR");
steroids.logger.log('data: ' + data);
steroids.logger.log('status: ' + status);
}).then(function(data, status, headers){
steroids.logger.log("Inside http.get() then");
});
steroids.logger.log("END CALL: processLogin");
}
});
从通话记录输出到steroids.logger.log
View Time Level Message
main#login 16:01:55.219 info "Inside http.get() WITH ERROR"
main#login 16:01:55.219 info "data: null"
main#login 16:01:55.219 info "status: 0"
main#login 16:01:55.64 info "END CALL: processLogin"
main#login 16:01:55.64 info "START CALL: processLogin"