W
W
Wasya UK2017-04-28 11:51:05
Node.js
Wasya UK, 2017-04-28 11:51:05

How to correctly set paths in Node?

When I go to the home page and the user page everything works, but when I try to go to another directory - an error. ATP in advance

// frontpage directory
    app.get('/', require('./frontpage').get);
    
    // another directories
    app.get('/edit', require('./edit').get);
    app.post('/edit', require('./edit').post);
    app.get('/messages', require('./message').get);
    
    // registration
    app.get('/registration', require('./registration').get);
    app.post('/registration', require('./registration').post);
    app.post('/registration/name', require('./registration').postName);
    app.post('/registration/avatar', upload.any(), require('./registration').postAvatar);
    app.post('/registration/about', require('./registration').postAbout);
    app.post('/registration/info', require('./registration').postInfo);
    app.post('/registration/secret', require('./registration').postSecret);
    
    // authorization
    app.get('/login', require('./login').get);
    app.post('/login', require('./login').post);
    app.get('/logout', require('./logout').get);
    
    // users
    app.get('/users', require('./users').get);
    
    // user
    app.get('/:id', require('./frontpage').user);

I suspect next() is the problem.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wasya UK, 2017-04-28
@dmc1989

You just need to check whether to call or not. And then it worked on any line passed to it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question