即使在任何地方使用cors,也不会出现“ Access-Control-Allow-Origin”错误

时间:2018-12-10 13:55:59

标签: node.js api cors fetch cors-anywhere

即使使用此代理后,我仍然出现以下错误:

  

访问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);

0 个答案:

没有答案