Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda