URL Generation for Routes in Express

前端 未结 3 755
迷失自我
迷失自我 2021-01-03 23:49

I\'m considering using Express framework in my next node.js project. However, a stumbling block for me is non-existence of URL generation for routes like in most other non-S

3条回答
  •  死守一世寂寞
    2021-01-04 00:31

    Or stick with express and use the package reversable-router.

    Example from the readme:

    app.get('/admin/user/:id', 'admin.user.edit', function(req, res, next){
        //...
    });
    
    //.. and a helper in the view files:
    url('admin.user.edit', {id: 2})
    

提交回复
热议问题