2016-12-02 79 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/ –