Differences between express.Router and app.get?

前端 未结 8 1028
终归单人心
终归单人心 2020-11-29 14:24

I\'m starting with NodeJS and Express 4, and I\'m a bit confused. I been reading the Express website, but can\'t see when to use a route handler or when to use

8条回答
  •  日久生厌
    2020-11-29 15:03

    using app.js to write routes means that they are accessible to all the users as app.js is loaded on application start. However, putting routes in express.router() mini apps protect and restrict their accessibility.

提交回复
热议问题