Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

external routes in nodejs api

var index = require('./routes/index');
app.use('/', index);

in your server.js / app.js

then index.js that is in /routes/ directory :

router.get('/', function (req, res) {
 // handle your route here
});

module.exports = router;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #external #routes #nodejs #api
ADD COMMENT
Topic
Name
7+8 =