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.