I want to refresh my page using respone and here is my code:
app.post("/delete",function(req,res){
res. <<-HERE I WANT TO REFRESH THE CURRENT PAGE USING "res."
})
If you think this question is stupid, please forgive me for that because iam a beginner :)
CodePudding user response:
You can either redirect the browser to the page URL after the delete action:
app.get("/", function(req, res) {
res.render("page.ejs");
});
app.post("/delete", function(req, res) {
/* Carry out deletion */
res.redirect("/");
});
or you can include the code that generates the page in both the GET and POST routes:
app.get("/", function(req, res) {
res.render("page.ejs");
});
app.post("/delete", function(req, res) {
/* Carry out deletion */
res.render("page.ejs");
});
The important point is that, in both cases, the rendering of the page must take into account the prior deletion. Without you sharing more of your code, we cannot judge whether that works in your case.