A
A
Abc Edc2015-01-27 16:54:27
Node.js
Abc Edc, 2015-01-27 16:54:27

How to transfer control from routes to node js?

There is a route

module.exports = function(app) {
app.get('/users', require('../controllers/user').CRUD.findAll);
app.get('/users/:id', require('../controllers/user').CRUD.findById);
app.post('/users/login', require('../controllers/user').handlers.login);
};

In the ap.js itself, the
call is like this
require('./routes')(app);
But in the controller
exports.handlers = {
    login: function(req, res, next){
К ПРИМЕРУ
req.json(req.params);

nichromenki will not return, what's the salt?
how to transfer rivers and res or some kind of control

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kazmiruk, 2015-01-27
@gleber1

req.params contains dynamic parameters, which, judging by the /users/login url, you simply do not have for this request. If you want to display there what is after ? (/users/login?q=1), then you need to use res.query for this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question