What does a colon mean on a directory in node js?

前端 未结 2 1944
星月不相逢
星月不相逢 2021-01-13 08:40

I\'m reading a book about nodejs/express and I\'m trying to reproduce the examples. I\'ve never seen a colon on a directory name, but I\'ve seen it a couple of times in this

2条回答
  •  太阳男子
    2021-01-13 09:13

    If you're talking about the :year or :month, there are URL parameters. You can get back with req.params.

    For exemple to get back this two arguments you can do something like :

    app.post('/contest/vacation-photo/:year/:month', function(req, res){
        // Get the year url parameter :
        var year = req.params.year;
    }
    

    Hope it help.

提交回复
热议问题