V
V
vasIvas2015-09-02 00:27:50
Node.js
vasIvas, 2015-09-02 00:27:50

Why is expressjs not seeing the path?

module.exports = (function(app){
    var index = require('./index');
    var users = require('./users');

    app.use('/users', users);
    app.use('/', index);
});

var express = require('express');
var router = express.Router();

router.get('/', function(req, res, next) {
    console.log('index');
    res.json({message: "index"});
});

module.exports = router;

var express = require('express');
var router = express.Router();

router.get('/users', function(req, res, next) {
    console.log('users');
    res.json({message: "users"});
});

module.exports = router;

Why can I make requests to index, that is, "/", but not to "/users", 404?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aves, 2015-09-02
@vasIvas

app.use('/users', router.get('/users', ...)) == app.get('/users/users', ...)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question