I want to use variable (or variables) in ejs file in the script tag ,I also want to pass the rendered file to a function for taking screenshot from ejs file.
But now I have 2 problems :
1.I don’t know how to pass the variable in server file to the ejs file and render and use it without app.get… (in express) because it’s server side and I want to use html file.
2.I don’t know how to use variable in ejs file in the script tag
these are my files :
index.ejs
<div id="tvchart"><% symbol %></div>
<script>
//some codes
var symbolD =<%= symbol %>;
fetch(`http://127.0.0.1:9665/fetchAPI?endpoint=https://api.binance.com/api/v3/klines?symbol=${symbolD}&interval=1m&limit=1000`)
</script>
server.js
// set the view engine to ejs
app.set("view engine", "ejs");
const symbol = "EGLDUSDT"
const file = ejs.render("./index.ejs" , symbol);
console.log(file)
So Why my ejs and server file doesn’t work?