To send the data to .ejs file, we use res.render() method. Now if that .ejs file has some .js file in script tag, how can we send the same data to .js file?
// Server file contains
app.get('/student/data_structures/mock_test_1', (req, res) => {
res.render('student/mock_test', { questions });
})
questions
is an array of objects
// mock_test.ejs contains
<script src="../../static/dom.js"></script>
In mock_test.ejs
file I have access to questions
, the question is how to have access to questions
in dom.js?