我收到此错误
请求资源上存在访问控制允许来源标题
Access-Control-Allow-Origin' header is present on the requested resource
我试图对instragram api发起$ .ajax调用。我使用 https:// api .instagram / v1 / tags / nofilter / media / recent?client_id = CLIENT-ID
I am trying to make a $.ajax call to the instragram api. I am using the api.instagram/v1/tags/nofilter/media/recent?client_id=CLIENT-ID
终点。我把我的客户端ID,我得到CORS错误。它找不到我的本地主机:3000,我不知道该怎么办。当测试时,端点在邮递员中工作。所以我知道它与CORS有关,但我不知道是谁设置其他选项。
end point. I have put in my client-ID and I get the CORS error. It can't find my localhost:3000, I don't know what to do. the endpoint works in postman when I tested. So I know it has something to do with CORS but I don't know who to set other options.
function getLooks(){
function getLooks(){
$.ajax({ url: "api.instagram/v1/tags/ootd/media/recent?client_id=someidnumbersxxxxxxxxxxxxxx", type: "GET", crossDomain: true, success: function(data){ console.log(data); _.each(data, function(look){ console.log(look); //var $look = template(look); //$("#looks-container").append($look); }); } });}
任何帮助或链接到其他材料将有所帮助。
Any have this issues. Any help or link to other material will help.
推荐答案您可以使用 dataType jsonp 用于GET请求。
You can use the dataType jsonp for GET requests.
$.ajax({ url: "api.instagram/v1/tags/ootd/media/recent?client_id=someidnumbersxxxxxxxxxxxxxx", type: "GET", crossDomain: true, dataType: "jsonp", success: function(data){ console.log(data); _.each(data, function(look){ console.log(look); //var $look = template(look); //$("#looks-container").append($look); }); } });更多推荐
instagram jquery ajax type =“GET,无法绕过CORS
发布评论