Every time a node script is run node app.js I need to update a list in the frontend, but it is not possible to manipulate DOM through node.
in HTML, I want to append children option tags to this
<body>
<select name="endpoints" id="endpoints"></select>
</body>
and on server side I came up with this
var endpointDropdown = document.getElementById("endpoints");
endpoints.forEach(function (item) {
let option = document.createElement("option");
endpointDropdown.appendChild(option);
option.innerHTML += item;
});
Every time I run the node script, an array is generated with the required items which I want to display on the frontend. Is there anyway so when I run the script, it passes the array to the js file and then updates the html?