1.问题描述,先贴代码和问题图
router.get('/share/:bbsid/:topicid', function (req, res, next) {
console.log(req.url)
console.log(req.originalUrl)
var reqdata = req.params;
request.post({url:'https://api.xxx.com/bbs/topicDetail/' + reqdata.topicid, form:{topicId: reqdata.topicid}}, function (err, httpResponse, body) {
body = JSON.parse(body);
var bbsInfo = body['return']
//请求评论数据
request.post({url: 'https://api.xxx.com/bbs/comments/' + reqdata.topicid, form: {topicId: reqdata.topicid, page: 1}}, function (err, httpResponse, body) {
body = JSON.parse(body)
var commentdata = body['return'];
res.render('share',{tree: commentdata,topicInfo: bbsInfo})
})
})
});
看打印的URL
首先这是访问一次页面发生的请求
第一次的值: /share/21/98
然户会自动发起第二次请求,但是这次就没有获取到第二个参数了!
第二次的值: /share/21/undefined
;
在线等!!!
我建议你排查客户端发起请求的代码,高概率是客户端js拼写的url就是
/share/21/undefined