Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
Pass value from one controller to another

I have two controllers. One is login.js and the another one is home.js. I want to redirect to home controller from login controller with a value. To redirect to home controller, i wrote,

response.redirect('/home');

But, i cannot pass value here. When rendering a view with a value,

data = {'value':'hello'};    
response.render('view_login',data);

I want to do the same thing. I can pass value while rendering to the view but not when changing controller. Can i do this?

response.redirect('/home',{data: data});
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

you can use query parameters for this. When you are redirecting your home page or any other controller then you can write like this

res.redirect(/<some controller>?data=<some data>)

and in that controller where you want to use this value..you can write like this

function login(req,res){
   var data = req.query.data;
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!