instagram jquery ajax type =“GET,无法绕过CORS

编程入门 行业动态 更新时间:2024-10-11 21:25:51
本文介绍了instagram jquery ajax type =“GET,无法绕过CORS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我收到此错误

请求资源上存在访问控制允许来源标题

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

本文发布于:2023-10-10 17:43:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1479294.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:jquery   instagram   ajax   CORS   type

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!