AngularJS - $ http 200但没有数据?

时间:2014-11-09 23:31:33

标签: angularjs http response

使用firefox REST客户端我可以获得响应对象并获得200次成功。但是在我的应用程序中,我的预检获得200,然后GET呼叫失败?

我该如何调试?

这是firefox restclient响应(响应正文中有一个json对象:

http://i.stack.imgur.com/Mre2V.png

这是我的应用代码:

$http({
     url: 'http://api.stubhub.com/search/catalog/events/v2?title="san"',
     dataType: 'json',
     method: 'GET',
     data: '',
     headers: {
         "Content-Type": 'application/json',
         "Authorization": 'Bearer {token}'
     }
}).success(function(response) {
        $scope.searchResponse = response;
}).error(function(error) {
        $scope.error = error;
});

这是我在chrome中得到的:

http://i.imgur.com/YL0esPB.png

我的授权令牌是正确的。我有一种感觉,这是角度默认标题干扰我的GET电话,但我不知道它可能是什么或浏览器相关的问题。我尝试过restangular但没有运气。有什么想法吗?

EDIT1:显然200个代码在预检OPTIONS GET上。我在浏览器控制台中得到了这个:

XMLHttpRequest cannot load https://api.stubhub.com/search/catalog/events/v2?title=%22san%22. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:9000' is therefore not allowed access. 

但是当我在firefox中执行此操作时,我会得到相同的东西,除了在响应中我看到内容长度好像有响应。答案就不存在了。

0 个答案:

没有答案