
code snippet
const router = Router()
router.route('/data')
.get(func1, func2)
func1 = (req, res) => {
const data = {
age: 32,
name: John,
email: JohnNash@google.com
}
res.set('Content-Type', text/json)
res.send(JSON.stringify(data))
res.locals.adata = data
next()
}
func2 = (req, res) => {
// You can see the data
console.log(res.locals.adata)
}