即使使用此代理后,我仍然出现以下错误:
访问CORS策略已阻止从原点“ null”获取“ https://crossorigin.me/www.metaweather.com/api/location/2487956/”的访问权限:请求的资源上没有“ Access-Control-Allow-Origin”标头
async function getWeatherAW(woeid) {
try {
const result = await fetch(`https://crossorigin.me/www.metaweather.com/api/location/${woeid}/`);
const data = await result.json();
const tomorrow = data.consolidated_weather[1];
console.log(`Temperatures tomorrow in ${data.title} stay between ${tomorrow.min_temp} and ${tomorrow.max_temp}.`);
return data;
} catch(error) {
alert(error);
}
}
getWeatherAW(2487956);