How to access optional URL parameters in Express.js?
<p>In Express.js 4.14, I have the following route:</p>

<pre><code>app.get('/show/:name/:surname?/:address?/:id/:phone?', function(req, res) {
    res.json({
        name: req.params.name,
        surname: req.params.surname,
        address: req.params.address,
        id: req.params.id,
        phone: req.params.phone
    });
});
</code></pre>

<p>If I request localhost:3000/show/luis/arriojas/California/123/456, I will receive:</p>

<pre><code>{"name":"luis","surname":"arriojas","address":"California","id":"123","phone":"456"}
</code></pre>

<p>Everything is OK with that, but if I request localhost:3000/show/luis/California/123, I will receive:</p>

<pre><code>{"name":"luis","surname":"California","id":"123"}
</code></pre>

<p>How could I get "California" as req.params.address instead of req.params.surname?</p>