【发布时间】:2021-03-05 11:06:51
【问题描述】:
从以下请求中,我得到状态代码 302 重定向。但我想发送从响应中收到的 cookie,并重定向到下一页。现在我在发送请求时收到状态码 401,我发现这是因为我需要将 cookie 与重定向一起发送,但是在我获取给我重定向的 url 之前我没有得到 cookie .我该怎么做?
async function login (url) {
let request = await fetch(url, {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
body: 'username=name&password=pass&submit=login',
})
return request
}
【问题讨论】:
标签: javascript cookies request http-headers http-post