mirror of
https://github.com/expressjs/expressjs.com.git
synced 2026-02-21 19:41:33 +00:00
24 lines
780 B
Plaintext
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"
|