how to get URI as parameters in NodeJS

How can i get the URI and use it as params in nodejs. I am using express.

http://localhost:3000/getParams/param1/param2/param3/paramN

I want to get "/param1/param2/param3/paramN".

This is my current code:

app.get("/getParams/:params", test.params);

Thanks!

You can access the full path as one param, or you can access each segment as a separate param. To get as one param:

app.get('/mysvc/:input(*)', function(req, res) 
                            { 
                                console.log(req.params.input);
                                // ...
                            });

Notice the route which says everything (regex match of *) after /mysvc/ will be mapped to the input reques param. Then you can reference it via req.params

In this example, a request to /mysvc/foo/bar will output foo/bar

If you want to get each segment as a separate param then:

    app.get('/mysvc/:param1/:param2'

access via req.params.param1, req.params.param2, etc...

In express parameters are available in the req object req.params.parameterName so in your case you can access it within the route like this req.params.params.

The params that you can access from the handler depends upon the route definitions. If you route is like

/my/:one/:two/:three

then you can access them as

req.params.one
req.params.two
req.params.three