I have a context in node.js called Blog which displays the blogs which users have inputed to the database on one webpage. I then have a method which after a user clicks on the blog then tries to display a webpage with just the one blog entry. It queries by the ID of the blog post here is the code in the app.js file.
const id = req.params.id;
console.log(id);
Blog.findById(id)
.then(result => {
res.render('details', { title: 'Blog details ', blog: result });
})
.catch(err => {
console.log(err);
});
});
Here is the details.ejs file which is supposed to output the blog post selected after the database query. The code finds the database ID as this in url header in chrome but the details page always shows as error 404. Please help
<html lang="en">
<%- include("./partials/head.ejs") %>
<body>
<%- include("./partials/nav.ejs") %>
<div class="details content">
<h2><%= blog._id.title %></h2>
<div class="content">
<p><%= blog._id.body %></p>
</div>
<a class="delete" data-doc="<%= blog._id %>">delete</a>
</div>
<%- include("./partials/footer.ejs") %>
</body>
</html>