收藏
回答

云函数 request-promise调用外部内容如何获取cookie?

在云函数使用request-promise调用外部网站数据,需要截取cookie中的值(如截图),我如何获取。谢谢!

最后一次编辑于  2020-01-06
回答关注问题邀请回答
收藏

2 个回答

  • Jerome
    Jerome
    2020-03-09

    有两个要点

    第一是 options里带上 resolveWithFullResponse: true

    第二是 你可以console.log(res); 来找到你需要的header

    var options = {
            uri: 'http://xxx.xxx.xxx.xxx:8081/' + rest_of_url,
            method: event["httpMethod"], //'GET'
            qs: event['queryString'],
            headers: event["headers"],
            resolveWithFullResponse: true
        };
    return await rp(options)
            .then(function (res) {
                console.log(res.headers);
            })
    
    2020-03-09
    有用 1
    回复
  • 121
    121
    2020-01-06

    没试过这样操作,,谢邀。。

    2020-01-06
    有用
    回复
登录 后发表内容
问题标签