2016-12-02 80 views
-1

我想使用stackoverflow的api在stackoverflow中的标签ipv4所有的问题。但我有以下错误No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.错误调用stackoverflow api

我已经在堆栈交换注册我的应用程序。但我不知道如何验证它。

您能有所帮助,教程或文档是非常欢迎

,这里是我的时刻码更多:

$http.get("http://api.stackexchange.com/docs/questions#order=desc&sort=activity&tagged=ipv4&filter=!BHMIbze0EPheMk572h0ktETsgnphhU&site=stackoverflow&run=true") 
      .success(function(data) { 
       console.log(data); 
      }); 
+0

及其API计算器测试 –

回答

1

即发出请求的URL是不正确你正确地连接到api网址?

下面是一个例子

$.ajax({ 
    url:'https://api.stackexchange.com/2.2/questions?order=desc&sort=activity&tagged=ipv4&site=stackoverflow&filter=!BHMIbze0EPheMk572h0ktETsgnphhV', 
    complete: function (response) { 
     $('#output').html(response.responseText); 
    }, 
    error: function() { 
     $('#output').html('Bummer: there was an error!'); 
    }, 
}); 

http://jsfiddle.net/heanfig/v5hLzmud/1/

+0

安德烈斯非常感谢你的回答。但是,你是什么意思你正确地连接到api网址? Iam对于angularjs和整个web开发来说都非常新颖。 –

+0

我的意思是,你做出错误请求的网址向你发送了一个使用了stackoverflow api的角色代码片段 而你请求的url返回HTML并产生了交叉源错误PS:对不起,我的英文不好: -O angularjs + stackoverflow api http://jsfiddle.net/heanfig/vsjy89bu/1/ –