node.js - Can we send data with redirect in node -
node.js - Can we send data with redirect in node -
i trying send info redirect as:
this.redirect("/home",{message:'hello'});
but got result like:
undefined redirect home
if faced problem, please help.
using framework: locomotive
yes, can utilize express-flash:
app.use(flash()); ... app.get('/redirect', function (req, res) { req.flash('info', 'flash message added'); res.redirect('/'); });
you info acessile in res.locals.messages
in views in messages
var.
express flash based on connect flash. uses sessions transmit messages.
if using locomotive
locomotive builds on express, preserving powerfulness , simplicity you've come expect node.
so:
module.exports = function() { ... this.use(express.bodyparser()); this.use(express.session({ secret: 'keyboard cat' })); this.use(flash()); ... }
node.js
Comments
Post a Comment