I've come across two different methods of defining routes in Node.js:
Method #1:
router.get("/", (req, res, next) => {
res.render("index", { title: "ABC" });
});
module.exports = router;
Method #2:
module.exports = (() => {
router.get("/", (req, res, next) => {
res.render("index", { title: "ABC" });
});
return router;
})();
I was curious, what's the main difference between these two? And, is there a major reason why one method is preferred over the other? Thanks!
via user3781239
No comments:
Post a Comment