【问题标题】:node.js - node-fetch returns null when cookies are receivednode.js - node-fetch 在收到 cookie 时返回 null
【发布时间】:2021-02-12 13:10:02
【问题描述】:

我有一个代码:

const fetch = require('node-fetch');

fetch('https://www.instagram.com/', {method: 'GET',  credentials: 'same-origin'})
.then((res) => {
    console.log(res.headers.get('set-cookie'));
})
.catch(err => console.log(err));

我想从响应中获取cookies,但res.headers.get('set-cookie') 返回null

我试过了:
res.headers['set-cookie']; //undefined
res.headers['cookie'] //undefined
res.headers.raw()['set-cookie']; //undefined
设置:credentials: 'include' //also don't work

我不知道是什么问题,我都试过了,请帮忙。

【问题讨论】:

    标签: node.js cookies fetch


    【解决方案1】:

    我也遇到过。官方文档说不支持凭据。 offical document

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-03
      • 1970-01-01
      • 1970-01-01
      • 2016-02-09
      • 1970-01-01
      • 2022-06-12
      • 2019-08-16
      • 2019-11-02
      相关资源
      最近更新 更多