【发布时间】:2020-02-09 15:01:15
【问题描述】:
我收到以下错误
crossorigin.me/:1 Failed to load resource: the server responded with a status of 522 ()
AJAX calls with FETCH and PROMISES.html:1 Access to fetch at 'https://crossorigin.me/https://www.metaweather.com/api/location/2487956/' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
AJAX calls with FETCH and PROMISES.html:18 TypeError: Failed to fetch
我尝试通过crossorigin.me解决,但没有成功
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Making AJAX calls with FETCH and PROMISES</title>
</head>
<body>
<script>
fetch('https://crossorigin.me/https://www.metaweather.com/api/location/2487956/')
.then(result => {
console.log(result);
})
.catch(error => {
console.log(error);
});
</script>
</body>
</html>
我期待着承诺的回应
【问题讨论】:
-
522 是 CloudFlare 的响应,表示目标服务器(
crossorigin.me或metaweather.com)无法访问。 -
有什么可能的解决办法吗?
-
不,你无能为力,只能给他们打个电话问一下
-
这个有没有替代的api?
-
没有
crossorigin.me是否可以工作,因为这是有问题的那个?
标签: javascript json ajax api