Closed JuanR9910 closed 2 years ago
So in your redirect, you need to redirect to /review/:id
bc you don't currently have a route for just /review
. And then try just deleting .render('/views/main404')
so that it just sends the status(400) without trying to render a page
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
Postgres, Psql, Express, Nodejs
What's the problem you're trying to solve?
When I try to post a comment I get redirected to a page without the 404 error
Post any code you think might be relevant (one fenced block per file)
``router.post('/:id', (req, res) => {
console.log(req.params.id)
console.log(req.body.content)
`console.log(res.locals.currentUser)
db.comment.create({
gameId: req.params.id,
content: req.body.content,
userId: res.locals.currentUser
})
.then((post) => {
res.redirect('/review')
})
.catch((error) => {
res.status(400).render('/views/main404')
})
})