Sunday, 12 March 2017

dysfunctional route configuration node-express

Why does this give me 404-NotFound?

var test = require('./routes/test');
app.use('/test', test);
router.get('/test', function (req, res, next) {
    //res.render('/test', { title: 'test' });
    res.send('respond with a TEST resource');
});

where this given me what is expected?

var test = require('./routes/test');
app.use('/test', test);
router.get('/', function (req, res, next) {
    //res.render('/test', { title: 'test' });
    res.send('respond with a TEST resource');
});

In either case res.send() & res.render() behave alike. The first response is 404-NotFound. The second is what you want to see.

Thanks for the help



via user2367083

No comments:

Post a Comment