Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

module.exports with JavaScript

mycoolmodule/index.js
module.exports = "123";


routes/index.js


var mymodule = require('mycoolmodule')

var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
	console.log(mymodule);
});
 
/*will show 123 in the terminal*/
module.exports = router;

Source by www.sitepoint.com #
 
PREVIOUS NEXT
Tagged: #JavaScript
ADD COMMENT
Topic
Name
6+1 =