Monday 22 February 2016

[Advice] Passing res to a shared function

What is the best way to do the following:function shared(req, res) { let filename = req.file.filename somePromise.then(() => { res.json({filename}); }) } module.exports.example = (req, res, next) { //more code here shared(req,res); } module.exports.example2 = (req, res, next) { //some other code here shared(req, res) } I think that this is ugly but that's what I came up with, given that the functions execute different code before using the shared one

Submitted February 22, 2016 at 11:27AM by cryptocool

No comments:

Post a Comment