I have this next GET function in express and in the res.render() function i'm sending to the EJS file the data i want to use, now my question is how can i use the data that i've sent to the EJS file in plain javascript in the same EJS file?
GET Funtion:
router.get('/:id', (req, res) => {
let pollId = req.params.id;
Poll.findById(pollId, (err, poll) => {
if(err) throw err;
Vote.find(pollId, (err, votes) => {
res.render('vote', {user: req.user, poll: poll, voteFail: req.flash('voteFail'),votes: votes });
});
});
});
And an example of how i want to use the data:
<script type="text/javascript">
console.log(<%votes%>);
</script>