javascript – Output Problem in Node.js and didn’t show exact value
Here is the code of for every blog’s title
Here is the code of content
<% posts.forEach(p => { %>
<% }) %>
And Here is my backend code
app.get("/myblog", async(req,res) => {
try{
const response = await axios.get(`${api_url}/posts`);
res.render("myblog.ejs", {
posts: response.data,
});
}
catch(error){
res.status(500).json({message: "Error fetching data"});
}
});
app.get("/myblog2", async(req,res) => {
try{
const response = await axios.get(`${api_url}/posts`);
res.render("myblog2.ejs", {
posts: response.data
})
}
catch(error){
res.status(500).json({message: "Heavily Error"});
}
});
app.get("/new", (req,res) => {
res.render("modify.ejs");
});
app.post("/api/posts", async(req,res) => {
try{
const response = await axios.post(`${api_url}/posts`, req.body);
res.render("myblog2.ejs");
}
catch(error){
res.status(500).json({message: "Error Creating Post"});
}
});
I want to show each title show their own content not other’s. But in my codes each title show other’s content as well.
So, What should can I do? How can I fix this ?
Thank You
Read more here: Source link
