I have this error when I'm trying to run this code:
Error UnhandledPromiseRejectionWarning: CastError: Cast to ObjectId failed for value "main.css" (type string) at path "_id" for model "FILM"
app.get('/films/:id', (req, res) => {
const id = req.params['id'];
FILM
.findById(id)
.then(item => res.render('template.ejs', {item}));
});
template.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="main.css">
<title>Template</title>
</head>
<body>
<header class="header">
<%- include('partials/header.ejs') %>
</header>
</body>
</html>
What does main.css
do in req.params
?