Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
100
rated 0 times [  101] [ 1]  / answers: 1 / hits: 17966  / 12 Years ago, mon, december 10, 2012, 12:00:00

I'm having some trouble deciphering the ambiguity between



res.render('viewname', {msg: 'Message' }) 


and



res.redirect('route')


The redirect function does not let you pass a message, but you may still want to, and the render function will render your view, but it will not change the URL of your web app and will not trigger the function which is required for your route.



The situation I am having is that I have an Invite form, which has an action that changes my URL, and triggers a function at that route which has a success and failure callback, and I would like to redirect users to the Dashboard with a message indicating success or failure.


More From » node.js

 Answers
198

look at connect-flash to use rails style flashing of messages.



res.render() will render the view with data passed to it, res.redirect() will redirect a user to another page (at which point the request starts over)


[#81515] Friday, December 7, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
stefanicarolinat

Total Points: 145
Total Questions: 91
Total Answers: 93

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
stefanicarolinat questions
Mon, Nov 15, 21, 00:00, 3 Years ago
Fri, Apr 16, 21, 00:00, 3 Years ago
Thu, Oct 15, 20, 00:00, 4 Years ago
Fri, Jul 17, 20, 00:00, 4 Years ago
;