In a small application made with Express.js, I print text to the console every second and after 4 seconds I stop the text output to the console. I need to return the current date to the page after the input to the console has expired. How can I do this?
var express = require("express");
var app = express();
app.get("/", (req, res) => {
const utcStr = new Date().toUTCString();
function outputText() {
console.log(utcStr);
}
const interval = setInterval(outputDate, 100);
setTimeout(() => {
clearInterval(interval);
}, 4000);
res.send();
});
app.listen(3000);