我尝试访问fetch
旧网站的URL,并发生了错误:
Fetch API cannot load http://xyz.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://abc' is therefore not allowed access.
If an opaque response serves your needs, set the request's mode to 'no-cors'
to fetch the resource with CORS disabled.
我理解了该消息,并尝试执行一个返回不透明响应的请求:
fetch("http://xyz", {'mode': 'no-cors'})
好的,现在可以了...但是我看不懂。= \
那么,不透明的响应的目的是什么?
Status code
始终是0
,如何检查是否成功status is never 200
?