WDI-SEA / project-4-issues

Open an issue to receive help on project 4 issues
0 stars 0 forks source link

Trying to post comments on review page #37

Closed JuanR9910 closed 2 years ago

JuanR9910 commented 2 years ago

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') }) })



### If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?

### What is your best guess as to the source of the problem?

### What things have you already tried to solve the problem?
tkolsrud commented 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