我正试图使用angularjs向“https://connect.squareup.com/v2/locations”发出请求,在那里呼叫失败,禁止使用403。
下面是代码示例:
var url = 'https://connect.squareup.com/v2/locations';
var config = {
headers: {
'Authorization': 'Bearer sandbox-sq0atb-JJGltCa375qzAyoQbjPgmg',
'Accept': 'application/json',
"X-Testing": "testing"
}
};
$http.get(url, config)
.then(
function (response) {
console.dir(response);
},
function (response) {
console.log("failed" + response)
}
);我已经用上面的样品做了一个小提琴。任何帮助都是非常感谢的。
http://jsfiddle.net/dx6tdrha/
发布于 2017-05-16 14:56:41
你看到这个错误了吗:XMLHttpRequest cannot load https://connect.squareup.com/v2/locations. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.?这意味着您不能通过前端Javascript (如AngularJS)访问API,您需要使用不同的实现,如Node.js、PHP等。
https://stackoverflow.com/questions/44003864
复制相似问题