I am trying to do a redirect in a post request, but it doesn't work for me. Here is the express.js code that should do it:
app.set('view engine','ejs');
app.use("/",express.static('public'));
app.post("/sendMovieData", async(req,res)=>{
console.log(req.body)
res.render("../view/movie-selected")
})
And also here is the fetch request.
let requestBody = {
"movieName": movie.getAttribute("data-movieName"),
"image": e.target.src,
"city": JSON.parse(localStorage.getItem("city_country")).city,
"country": JSON.parse(localStorage.getItem("city_country")).country
}
fetch('/sendMovieData', {
method: "POST",
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify(requestBody)
});