从本地主机向 Square-Connect 发出请求时请求 Forbidden 403
Request Forbidden 403 when request made to Square-Connect from localhost
我正在尝试使用 angularjs 向“https://connect.squareup.com/v2/locations”发出请求,但调用失败,显示 403 FORBIDDEN。
这是代码示例:
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)
}
);
我已经制作了上述示例的 fiddle。感谢任何帮助。
您是否看到此错误: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等
我正在尝试使用 angularjs 向“https://connect.squareup.com/v2/locations”发出请求,但调用失败,显示 403 FORBIDDEN。
这是代码示例:
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)
}
);
我已经制作了上述示例的 fiddle。感谢任何帮助。
您是否看到此错误: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等