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

118
Vistas
Accessing handlebars object variable via javascript

I am using this code on the server side

app.get('/private', requiresAuth(), function (req, res) {
...
    res.render('private', {ListOfLoggedUsers: ListOfLoggedUsers});

What am I sending to the client is an array of objects which looks like this

[
  {
    userid: 'npwtest2',
    useridtimestamp: '2021-11-05T15:44:15.516Z',
    latitude: undefined,
    longitude: undefined
  },
  {
    userid: 'npwtest3',
    useridtimestamp: '2021-11-05T15:44:30.028Z',
    latitude: 15.7855745,
    longitude: 15.9264816
  },
  {
    userid: 'npwtest2@malinator.com',
    useridtimestamp: '2021-11-05T15:45:12.515Z',
    latitude: 55.7855745,
    longitude: 15.9264816
  }
]

On the client side I am using handlebars to access this variable:

<div>
        {{#each ListOfLoggedUsers}}
        <div class="row">
            <div class="col-md-12">
                <p>Logged user id: {{userid}}, Login date: {{moment useridtimestamp     format="DD.MM.YYYY HH:mm:ss"}},
                    Latitude: {{latitude}}, Longitude: {{longitude}} </p>
           </div>
        {{/each}}
</div>

This part is working fine, I am getting output which I want

I am trying to access those ListOfLoggedUsers from inline java script but without any success

<script>

var loggedUser = {{ListOfLoggedUsers}}

or 

var loggedUser = [{{ListOfLoggedUsers}}];
console.log (loggedUser)
    
</script>

Any idea how can access this array of objects inside inline javascript ? Thanks in advance.

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