I am new to web development and cannot figure out how to send data from the Node server to the client while also serving an HTML page. I know that res.send() sends the data but I cannot use that without also changing the client display. Here is some code of what I'm trying to do (but does not work)
Server:
app.get('/home', function (req, res) {
res.send("String with info I want in HTML");
res.sendFile(__dirname + '/home.html');
});
Client:
<script>
var xhttp = new XMLHttpRequest();
alert(xhttp.responseText); //Using alert to check if I received the info I wanted
</script>