node.js express node-fetch

事情是这样的,我在路由里获取用户信息然后通过req.session.userInfo = body;进行设置。
可是会话设置是失败的。
为何?

router.get('/', function(req, res, next) {

    var _id = req.query.UserID;

    if (_id) {

        fetch('https://github.com/')

            .then(function(res) {

                return res.text();

            }).then(function(body) {

                console.log(body);

            });

        res.render('index', { title: 'Express', UserName: 'nickname' });

    }

});


慕哥9229398
浏览 847回答 3
3回答

慕桂英546537

因为fetch是不带cookie的 所以服务端是读不到的
打开App,查看更多内容
随时随地看视频慕课网APP