【发布时间】:2018-10-10 07:38:49
【问题描述】:
我在前端应用程序上使用express 框架和react 来管理节点应用程序上的http 请求。一个有方法:
app.get('/api/matches', async (req, res) => {
console.log(req.originalUrl); // /api/matches/
console.log(req.query); // {}
...
当我使用像http://localhost:3000/matches?id=123 这样的url 时,我希望在req.query 对象中得到id,但我得到的是空的{} 对象。我还尝试检查express 如何使用originUrl 对象查看url,它在没有query ?id=123 的情况下返回。
【问题讨论】:
-
您使用的是
http://localhost:3000/matches?id=123,而不是http://localhost:3000/api/matches?id=123。这是笔误吗?
标签: javascript node.js http express