Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么不能在fetch';谁的反应?_Javascript_Httpresponse - Fatal编程技术网

Javascript 为什么不能在fetch';谁的反应?

Javascript 为什么不能在fetch';谁的反应?,javascript,httpresponse,Javascript,Httpresponse,我正试图从获取的响应中截取设置Cookie: fetch('https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png', { 方法:“获取” }).然后(功能(响应){ for(变量对response.headers.entries()){ log(`${pair[0]}:${pair[1]}`); } });您无法读取设置Cookie标题,因为它被声明为禁止。github上

我正试图从
获取
的响应中截取
设置Cookie

fetch('https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png', {
方法:“获取”
}).然后(功能(响应){
for(变量对response.headers.entries()){
log(`${pair[0]}:${pair[1]}`);
}

});您无法读取
设置Cookie
标题,因为它被声明为禁止。github上的
fetch
polyfill提供了一个合理的解释:

与XMLHttpRequest一样,Set Cookie响应头从 服务器是禁止的标头名称,因此无法删除 使用response.headers.get()以编程方式读取。相反,它是 浏览器负责处理设置的新cookie(如果 适用于当前URL)。除非它们仅限于HTTP,否则新cookie 将通过document.cookie提供


无法加载获取APIhttps://google.com/. 请求的资源上不存在“Access Control Allow Origin”标头。起源'https://www.google.com因此,不允许访问。如果不透明响应满足您的需要,请将请求的模式设置为“无cors”,以获取禁用cors的资源。
@guest271314这是因为我找不到任何具有
访问控制允许来源的网站:
。如果您知道任何问题,请告诉我。使用
“/”
作为
控制台当前问题的URL
@guest271314没有帮助,它会导致相同的错误!