express.js
でフレームワークを使用していnode.js
ます。app.get()
コールバック内から最初の文字列引数の値を取得しようとしています。
app.get('/example/code', function(req,res){
console.log(firstParam); // "/example/code"
});
app.get('/example/:id', function(req,res){
console.log(firstParam); // "/example/:id"
});
app.get('/example(s?)', function(req,res){
console.log(firstParam); // "/example(s?)"
});
これを行う方法はありますか?ご覧のとおり、URLは正確には必要ないので、ルートの要素は何でしたか。2番目の例では、戻りたくない/example/2