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

150
Views
How to pass information from a controller to a partial view

I'm having a problem with express and I don't know how to fix it. I would like to be able to pass information from the controller to a partial view (a header). The problem is that when I access a view other than the one I render in the controller, it breaks. How can I pass information to one view and make it work in all of them.

    const indexController = (req, res) => {
      let emailSession;
      if(req.session.userLogged == undefined){
          emailSession = "";
      } else {
          emailSession = req.session.userLogged.email
      }

      db.Users.findOne({
          where: {email: emailSession}
      }).then((data) => {
        res.render('index', {data}) //I want here to send the same variable to all of my views that has the same header, not just the index view
      )
    }
  <nav>
    <% if(data.info == "something") {%>
      <a href="">Dashboard</a>
    <% } %>
  </nav>

about 4 years ago · Juan Pablo Isaza
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!