Files
expressjs.com/en/api/req-params.jade
TJ Holowaychuk 9e957d4e2c Initial commit
2012-07-31 20:33:12 -07:00

24 lines
780 B
Plaintext

section
h3(id='req.params') req.params
p.
This property is an array containing properties mapped to the named route "parameters".
For example if you have the route <code>/user/:name</code>, then the "name" property
is available to you as <code>req.params.name</code>. This object defaults to <code>{}</code>.
+js.
// GET /user/tj
req.params.name
// => "tj"
p.
When a regular expression is used for the route definition, capture groups
are provided in the array using <code>req.params[N]</code>, where <code>N</code>
is the nth capture group. This rule is applied to unnamed wild-card matches
with string routes such as `/file/*`:
+js.
// GET /file/javascripts/jquery.js
req.params[0]
// => "javascripts/jquery.js"