Existing Code:
const express = require('express');
const router = express.Router();
router.get('/data/:d1/:d2/:d3', require('../apifoo').foo);
Route:
/data/:d1/:d2/:d3
Path:
/data/1/2/3
req.params :
'd1' :'1',
'd2': '2',
'd3': '3'
But what if the number of parameters is not known in advance? I tried to define these parameters dynamically by means of regular expression::
router.get(/\/data(\/\d+){1,}$/, require('../apifoo').foo);
RegExp:
/\/data(\/\d+){1,}$/
Path:
/data/1/2/3
req.params :
'0' : '/3'
Unfortunately it doesn't work! Is it possible to obtain the same 'req.params' like in example above, using RegExp or somewhat else?