Javascript 如何在服务器401响应中使用头
服务器正在使用摘要身份验证方法,我发出一个请求并得到401响应,在WWW身份验证字段的当前位置,我得到了执行第二个身份验证请求所需的内容,但无法提取它以使其工作Javascript 如何在服务器401响应中使用头,javascript,get,digest-authentication,response-headers,Javascript,Get,Digest Authentication,Response Headers,服务器正在使用摘要身份验证方法,我发出一个请求并得到401响应,在WWW身份验证字段的当前位置,我得到了执行第二个身份验证请求所需的内容,但无法提取它以使其工作 async function doRequest() { let response = await fetch('URL', { method: 'GET', mode: 'no-cors', headers: { Accept: '*/*',
async function doRequest() {
let response = await fetch('URL', {
method: 'GET',
mode: 'no-cors',
headers: {
Accept: '*/*',
},
})
alert(response.headers.get('Content-Type'));
}
如何操作这些标题?尝试以下操作:
async function doRequest() {
let response = await fetch('URL', {
method: 'GET',
mode: 'no-cors',
headers: {
Accept: '*/*',
},
})
return response;
}
doRequest()
.then(response => alert(response.headers.get('Content-Type')););
在本例中为“null”