Hüseyin Okumuş Hüseyin Okumuş -4 years ago 118
Node.js Question

How to set set url parameter with special character in node js?

I want setting like this

localhost:3000/some-special-days-one--parameterThat


How Can I setting and getting in router like this url and parameter in node js express framework?

Answer Source

I think that this is what you are trying to do:

var express = require('express');
var app = express();

app.get('/', function(req, res){
  res.send('hello world');
});

app.get('/firstParameter/:id', function (req, res) {
  res.send('my id is: ' + req.params.id);//this is the id
}); 

app.listen(3000);

In this example, if the user went to the URL localhost:3000/firstParameter--/someId, The page would show "my id is: someId".

Hope this helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download