How do I get express to change the content of an HTML element?

Viewed 15

Basically I want to use express to change the content of a paragraph element to the value of a random variable from a list.

This should not be so difficult but I have zero clue what I am doing wrong.

Basically I have a paragraph element in index.html

<p id="question"></p>

And in app.js I have this:

app.get('/', async (req, res) => {
  res.sendFile(__dirname + '/index.html');
  db = await connectToCluster();
});

I want to make it so the content of the paragraph element is set to a random entry from the database.

0 Answers
Related