[英]net::ERR_CONNECTION_RESET, Uncaught (in promise) TypeError: Failed to fetch
I'm new to JavaScript and it's my first time ever using an API.我是 JavaScript 新手,这是我第一次使用 API。 so I was trying to fetch the MetaWeather API that's how I did it
所以我试图获取 MetaWeather API 这就是我所做的
fetch('https://crossorigin.me/https://www.metaweather.com/api/location/2487956/');
<!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>Asynchronous JavaScript</title> </head> <body> <h1>Asynchronous JavaScript</h1> </body> </html>
I get those two errors and I really don't understand why.我收到这两个错误,我真的不明白为什么。
asynchronous.html:101 GET https://crossorigin.me/https://www.metaweather.com/api/location/2487956/ net::ERR_CONNECTION_RESET (anonymous) @ asynchronous.html:101 asynchronous.html:1 Uncaught (in promise) TypeError: Failed to fetch asynchronous.html:101 GET https://crossorigin.me/https://www.metaweather.com/api/location/2487956/net::ERR_CONNECTION_RESET (匿名)@asynchronous.html:101 asynchronous.html:1 Uncaught (承诺)类型错误:无法获取
Try to place the url succeeding this proxy: https://cors-anywhere.herokuapp.com/ instead of https://crossorigin.me/尝试将 url 放在此代理之后: https : //cors-anywhere.herokuapp.com/而不是https://crossorigin.me/
It worked for me.它对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.