Trying to render a new page using ejs. I don't have a big experience with js. Managed good progress so far but at this point I'm stuck. Currently building a blog, and so far can render the about, or contact pages easily. When a new user adds a new post, I'm trying to render a new page for that post at localhost:3000/post/test (test is the name of the post). I receive : Cannot GET /post/title. If with the same code I only try to check the equality between const storedTitle and const requestedTitle, and if true, console.log("match found") that works just fine. When using the code below, it doesin't work anymore. Below is the code I've written for that, but probably in order for one to help me out here, he/she would need to see more than that. This is my first post on here, sorry if in any case, it does not comply with the community policy. Thanks for the help!
app.get("/posts/:nameOfPost", function(req, res) { const requestedTitle = _.lowerCase(req.params.nameOfPost);
posts.forEach(function(post) { const storedTitle = _.lowerCase(post.titleInput);
if (storedTitle === requestedTitle) {
res.render("post", {
title:post.title ,
content:post.content
});
};
});