Reputation: 13970
In Express 4 I'm not receiving all the query string paramters, only the first one. Curl shows some weird output that I don't know how what means.. I'm using cors and mongoose-pagination modules.
What's happening here?
Using curl: curl http://localhost:3000/products?_dc=1465158748756&page=1&start=0&limit=25
In app.js:
//Enable CORS
app.use(cors());
app.options('*', cors());
app.use('/', routes);
app.use('/users', users);
app.use('/products', products);
In product controller:
/* GET products listing. */
router.get('/', function(req, res) {
var page = req.query.page ? 1 : req.query.page;
//var start = req.query.start;
var limit = req.query.limit ? 1 : req.query.limit;
db.product.paginate({}, { page: page, limit: limit }, function(err, p){
if(err){
console.log(err);
//Error
res.status = 500;
return res.send(new Error(err));
}
return res.send(p);
});
});
The req.query only contains the first parameter:
req.query
Object
_dc: "1465158748756"
__proto__: Object
This is the curl's output, I don't know how to interpret this:
oscar@dlp-AOD255E:~/node/HomeInventoryServer$ curl http://localhost:3000/products?_dc=1465158748756&page=1&start=0&limit=25
[1] 3471
[2] 3472
[3] 3473
Upvotes: 0
Views: 115
Reputation: 13970
Ok, just for the records, it seems that I need to put the url inside quotes " as curl interprets it in a different way.
curl "http://localhost:3000/products?_dc=1465158748756&page=1&start=0&limit=25"
Upvotes: 1