简体   繁体   中英

Sails.js redirect with param

what is the best way to redirect inside a Sails.js Controller from one route to another and transfer some data at the same time. My situation is that I've got one route that creates some data and the redirects back to another route. My problem is that I don't know how to transfer an error message (if one happens) back to the other route (because I want to display it there).

Bruno

My problem is that I don't know how to transfer an error message (if one happens) back to the other route (because I want to display it there).

Sails@v0.12 includes flash middleware in form of https://github.com/jaredhanson/connect-flash :

req.flash('error', payload);
res.redirect(307, '/');
return;

To get the error in another controller:

var error = req.flash('error');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM