开发者

Special Chars like DOTS in Express.js route?

开发者 https://www.devze.com 2023-03-07 14:46 出处:网络
i got the following node.js / express.js method: 开发者_Python百科app.post(\'/pin/save/:latitude/:longitude\', function(req, res) {

i got the following node.js / express.js method:

开发者_Python百科app.post('/pin/save/:latitude/:longitude', function(req, res) {
...
}

the values that get assigne to latitude and longitude include dots, e.g. 16.33245 / 46.28473. the problem is, express.js tells me that it can't GET that url. removing the dots it works... any advice how i can get express to accept the dots in the route?

thanks


Do you gave a route defined for get in addition to the one for post? I tried this and it worked fine:

app.get('/test/:lat/:long', function(req, res){
  res.send("lat:" + req.params.lat + " long:" + req.params.long);
});

with:

/test/1.2/3.4

gave me:

lat:1.2 long:3.4
0

精彩评论

暂无评论...
验证码 换一张
取 消