显示FetchAPI POST请求的响应Cookie

时间:2019-11-16 16:00:22

标签: javascript post fetch-api

我正在寻找一种方法来登录控制台,以获取POST请求的响应cookie,但是我不知道该怎么做。 例如此处: 我想在控制台中显示响应cookie名称及其值。

我已经发出了获取请求,在这里:

let headers = new Headers({
    "Content-Type"       : content-type,
    "User-Agent"   : user-agent
});

fetch(url, {
    method: "POST",
    headers: headers,
    credentials: 'include',
body: "param=value"
})
.then((res) => res.json())
.then(function(data) {
    console.log(data);
})
.then(function(error) {
    if (error) {
        console.log(error)
    }
})

我还添加了credentials: 'include'来获取cookie,但只是不知道如何打印它们。

0 个答案:

没有答案