this is the line of code i am using to show the blogdata wrt email but it is showing cannot GET /myblog
app.get("/myblog/:e_mail", async (req, res) => {
const requestedEmail = req.params.e_mail;
try {
const user = await User.findOne({ email: requestedEmail });
if (!user) {
throw new Error("User not found");
}
if (!user.selfBlog) {
throw new Error("User does not have a self-blog post");
}
const post = user.selfBlog;
res.render("myblog", {
title: post.title,
content: post.content
});
} catch (error) {
console.error("Error fetching post:", error);
res.status(404).render("error", { errorMessage: "Post not found!" });
}
});
i tried to get the data in my db but got the error specified and it is my first time writing here so sorry for any mitake and as english is not my first language so sorry for any error in my english Thank you
Via Active questions tagged javascript - Stack Overflow https://ift.tt/VJcXN4D
Comments
Post a Comment