I would like to pass into the client - in addition to the html page a JSON
res.sendFile(path.join(__dirname, 'build/index.html'), {aaa: "asdsadaod"});
so I'll be able to do something like this in the html code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>XXX</title>
<script>
const a = "{{aaa}}"
alert(a)
</script>
</head>
<body>
YYY
</body>
</html>
is it possible ?
sendFile has no way to do that. It just sends a file.
Instead, pick a template engine and use res.render().