I am using Sails JS, PostgreSQL stack.
I want to pass two ids as parameters at the end of a url as below:
/getLocation/cc/re
Where 'cc' is a two letter country code e.g US and 're' is a an autocomplete query for a region of the country referred to in 'cc'
While using only cc works , adding the extra parameter results in a 'Not Found' page.
Here is the 'config/routes':
'get /location/getRegion/:cc/:re': 'LocationController.getRegion'
Pointing to say:
'localhost/location/getRegion/us/or'
results in a 404.
While:
'localhost/location/getRegion/us'
Works but obviously this outputs all regions/states in the us. The second parameter is supposed to filter this result further using 'contains'
Any ideas on how I can achieve the desired result using the two parameters?
Here is the
getRegion
code in my
LocationController
module.exports={
getRegion:function(req, res, next){
Regions.find({where:{country_code:req.param('cc')},region:{'contains':req.param('id')}},function selectRegions(err, regions){
console.log(req.param('cc'))
if(err) return next(err);
if(!regions) return next();
console.log(regions)
res.json(regions)
})
}
}