简体   繁体   English

当我将Angularjs与instagram API一起使用时,CORS错误

[英]CORS error, when i use instagram API with angularjs

I have simple task - get users' data from instagram account. 我的任务很简单-从instagram帐户获取用户数据。 I use standard instagram api and angularjs. 我使用标准的instagram api和angularjs。

Here is controllers' request method: 这是控制器的请求方法:

 $http({
  method: 'GET',
  url: 'https://api.instagram.com/v1/users/6976008122/media/recent/?access_token=1030475459.50cd673.aa04db13898d4fsd9ff8fe5095b32f34&scope=public_content&count=4'
    }).then(function(res) {
      console.log(res);
    }, function(err) {
      console.log(err);
    });

But I always get this error message: 但我总是收到此错误消息:

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. 对预检请求的响应未通过访问控制检查:请求的资源上不存在“ Access-Control-Allow-Origin”标头。 Origin ' http://project.loc ' is therefore not allowed access. 因此,不允许访问源“ http://project.loc ”。 The response had HTTP status code 405. 响应的HTTP状态码为405。

The first few pages of Google search has not helped, please help me understand and solve this problem. Google搜索的前几页没有帮助,请帮助我了解并解决此问题。

Use jsonp, there's a good example located here: JSONP Instagram 使用jsonp,这里有一个很好的例子: JSONP Instagram

Here's a link to another Stack Overflow question that explains how to do jsponp with angular Angular Jsonp 这是另一个Stack Overflow问题的链接,该问题解释了如何使用Angular Angular Jsonp进行jsponp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM