node.js - req param returns an empty array -


i using node.js , mongodb geolocation app , req param returns empty array

exports.findpressure = function(req, res) { var queryobject = req.param('q'); console.log(queryobject); db.collection('pressure', function(err, collection) { collection.find( { loc: { $near :[  req.param('q') ] , $maxdistance : 5 }},{"value" : 1, _id : 0})  .sort({_id : -1}).limit(1).toarray(function(err, items)    {                       res.send(items);                  }); }); }; 

the longitude , latitude values displayed in console

listening on port 3000...  connected 'weather' database  8.9068256,52.019347499999995  /pressure?q=8.9068256,52.019347499999995 200 27ms - 2b 

the url follows

http://localhost:3000/pressure?q=8.9068256,52.019347499999995 

if use values 8.9068256,52.019347499999995 getting value database if use req.param('q') returning empty array

you seem passing values part of query string. req.query.q should contain comma-separated values

edit: looking @ req.param() should grabbing query value. expecting values strings? should separate strings? @ least array might need given req.param('q').split(','). if need numbers, req.param('q').split(',').map(function(val) {return +val;});.


Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -