I like to get the req, res, next objects outside the middleware function.
sample middleware - sample.js:
var app = express();
....
.....
....
var updateUserInput = {
init:function(){
get_data_from_db(params, function(){
// want req, res here.
})
}
}
const processUserInput = function(req, res, next){
updateUserInput.init();
}
module.exports = processUserInput;
via NSK
No comments:
Post a Comment