I'm using express server with ejs templates for client and im passing an object not a single variable from server to client side.. like
router.get('/users/info',(req,res)=>{
let data = {
name:"myName",
email:"me@email.com",
address:"x,y,z",
coordinates:{ lat:34.545, lng:78.345 }
}
res.render('myEJSfile',{data});
})
In myEJSfile.ejs file
<div id="_data" data-params="<%=data.name%>"></div>
<script>
let data = document.getElementById('_data').dataset.params;
console.log(data);
</script>
OUTPUT : myName
which is expected output
But when I try to log whole object.. Again in myEJSfile.ejs :
<div id="_data" data-params="<%=data%>"></div>
<script>
let data = document.getElementById('_data').dataset.params;
console.log(data);
</script>
OUTPUT : [object Object]
here i want to display a complete valid object passed as a parameter from server side as i need to access on each and every attribute of this object seperately
Guys im stuck i have no other way in this particular situation get me out of this