javascript - Best way to pass route params between callbacks in expressjs -
i've tried search similar problem on here suprisingly couldn't find 1 posted already. i use expressjs v4 framework , i'm constructing routes this: 'use strict'; let express = require('express'); let router = express.router(); let users = require('./modules/users'); router.post('/',users.add); router.put('/edit/:id',users.edit); as can see above, i'm requiring let users = require('./modules/users') now users module looks (let's say) this: 'use strict'; let usersdbmodule = require('...'); let users = { 'add': (req, res, next) => { let callback = (err, record) => { //...do users.function1(record) } usersdbmodule.save(req, callback); }, 'function1': (record) => { users.function2() }, 'function2': () => { //...do next() function } } you can notice, router first...