我目前正在使用Express编写一个Web应用程序,我希望能够使用request.param
来提取可能在URL字符串(对于GET
)或在请求正文(用于POST)。
我已将请求对象传递给一个函数,该函数除其他外执行req.param('email');
但是,此代码段会引发以下错误:
TypeError: Object #<ServerResponse> has no method 'param'
at read_url_params (/home/louist/Documents/node/socialube/modules/user_verif.js:50:63)
at /home/louist/Documents/node/socialube/modules/user_verif.js:43:20
at Promise.<anonymous> (/home/louist/Documents/node/socialube/modules/user_verif.js:73:13)
at Promise.<anonymous> (/home/louist/Documents/node/socialube/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
at Promise.emit (events.js:95:17)
at Promise.emit (/home/louist/Documents/node/socialube/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
at Promise.fulfill (/home/louist/Documents/node/socialube/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
at /home/louist/Documents/node/socialube/node_modules/mongoose/lib/query.js:1394:13
at model.Document.init (/home/louist/Documents/node/socialube/node_modules/mongoose/lib/document.js:250:11)
at completeOne (/home/louist/Documents/node/socialube/node_modules/mongoose/lib/query.js:1392:10)
我尝试过包含bodyParser中间件,但无济于事。
我该如何解决这个问题?