How to fixed set the request's mode to 'no-cors'?

白昼怎懂夜的黑 提交于 2020-06-26 14:56:16

问题


I am currently using yahoo weather api to fetch weather data. I am getting below error. Please help.

Access to fetch at 'https://weather-ydn-yql.media.yahoo.com/forecastrss?location=sunnyvale,ca&format=json' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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.

I have tried to do google, but none of solution worked for me


回答1:


You can set the request mode to 'no-cors' like so:

fetch(url, {
    mode: "no-cors",
    ...
})


来源:https://stackoverflow.com/questions/54301686/how-to-fixed-set-the-requests-mode-to-no-cors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!