Answers for "difference between express() and express.router()"

0

difference between express() and express.router()

var express = require('express'),
    dogs    = require('./routes/dogs'),
    cats    = require('./routes/cats'),
    birds   = require('./routes/birds');

var app = express();

app.use('/dogs',  dogs);
app.use('/cats',  cats);
app.use('/birds', birds);

app.listen(3000);
Posted by: Guest on October-29-2020
0

difference between express() and express.router()

var express = require('express');

var router = express.Router();

router.get('/', function(req, res) {
    res.send('GET handler for /dogs route.');
});

router.post('/', function(req, res) {
    res.send('POST handler for /dogs route.');
});

module.exports = router;
Posted by: Guest on October-29-2020

Code answers related to "difference between express() and express.router()"

Code answers related to "Javascript"

Browse Popular Code Answers by Language