The official document says,req.query,
This property is an object containing a property for each query string parameter in the route. If there is no query string, it is the empty object, {}.
When I run my application ,
app.use(function(req, res, next) {
req.query
console.log(req.query); // undefined
console.log(req.query()); // "a=3&b=2"
next();
});
then req.query is a function named getQuery() , not an object,why?
my express version is 4.16.2.
I found the cause of the problem,Because the ‘bpmn’ package required.Here's my test code:
const express = require('express');
const http = require('http');
const bpmn = require('bpmn');
let app = express();
app.use(function(req, res, next) {
console.log(req.query); //[Function: getQuery]
next();
});
http.createServer(app).listen(8888, '0.0.0.0');
//node V8.9.0
//dependencies: "bpmn": "^0.2.2","express": "^4.16.2"
Hey What is your Issue Be specific on your topic I don't understand What you are asking about
{req.query}
@Muthukumars1994 Sorry,I have changed my issue
Form My Point of View -->
req.query = {} ==> It's a bundled Object with req Params
function (req, res) {
console.log(req)
console.log(typeof(req.query)); ==> it is a object not a function
console.log(req.query()) ==> what you are trying to do with That
}
'req.query' was good before. There was a problem with my project upgrading Express to 4.16.2 , after upgrad 'req.query' is a function , It's NOT a bundled Object with req Params.
Hi @czjs2 there hasn't been any changes around req.query recently and our test suite is showing it working just as you are expecting. There may be something in your app that is causing the issue and we need more information in order to help. Please provide all the following:
Thank you!
@dougwilson I found the cause of the problem,Because the ‘bpmn’ package required.Here's my test code:
const express = require('express');
const http = require('http');
const bpmn = require('bpmn');
let app = express();
app.use(function(req, res, next) {
console.log(req.query); //[Function: getQuery]
next();
});
http.createServer(app).listen(8888, '0.0.0.0');
//node V8.9.0
//dependencies: "bpmn": "^0.2.2","express": "^4.16.2"
Tracing it through, the BPMN package depends on Restify and Restify clobbers request.query no matter what; this is the exact line.
The issue is an issue with Restify and has already been raised at Restify:#1540. It is not an issue with Express. It may also be an issue that you'd raise with BPMN but given that BPMN project has been quiet for over a year I would personally advise that you be cautious with using it unless you are prepared to do maintenance for it.
@crdrost Thanks a lot!
I don't think there is anything we can do about this in this module, does anything know otherwise? If we undo the global modification that Restify does, that would then just break Restify.
@dougwilson that would be my take as a random person who happened to drop in on this conversation, yes: I'd say close this issue as "not our problem."
Most helpful comment
Tracing it through, the BPMN package depends on Restify and Restify clobbers
request.queryno matter what; this is the exact line.The issue is an issue with Restify and has already been raised at Restify:#1540. It is not an issue with Express. It may also be an issue that you'd raise with BPMN but given that BPMN project has been quiet for over a year I would personally advise that you be cautious with using it unless you are prepared to do maintenance for it.