Hi I'm new into EJS templates and I am trying to create a template for a simple web app, but when I run the app.js file into the HyperTerminal it gives me his error: "TypeError: Router.use() requires a middleware function but got a string at Function.use " Why this happens?????
My javascript code is:
const express=require("express");
const bodyParser=require("body-parser");
const app = express();
app.use('view engine', 'ejs');
app.get("/", function (req, res){
var today = new Date();
var currentDay = today.getDay();
var day = "";
switch (currentDay) {
case 0:
day="Sunday";
break;
case 1:
day="Monday";
break;
case 2:
day="Tuesday";
break;
case 3:
day="Wednesday";
break;
case 4:
day="Thursday";
break;
case 5:
day="Friday";
break;
case 6:
day="Saturday";
break;
default:
console.log("Error");
}
res.render("list", {kindOfDay: day});
});
app.listen(3000, function(){
console.log("Server is good and runnning")
});
and my ejs file is:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>To do List</title>
</head>
<body>
<h1>It's a <%= kindOfDay %>!</h1>
</body>
</html>