Closed isaac8069 closed 2 years ago
sounds like a url route issue, you'll need to declare that route with /:id
and set up a view template(something like show.ejs
that will take that apartment and render it to the page.
DEFINITELY too late to start over, but you don't need to! Trying to set up a new app wont make the content click any more than it is now.
Share here what that route I mentioned above might look like, and also share some ejs that you would use to render that content on the screen, we'll hammer out the bugs from there
router.get('/:id', (req, res) => {
db.apartment.findOne({
// include: [db.tag],
where: { id: req.params.id }
}).then((apartment) => {
res.render('apartments/show', { apartment: apartment })
}).catch((error) => {
console.log(error)
res.send('display apartments')
})
})
SHOW.EJS
<h1>Apartment: <%= apartment.title %></h1>
<p><%= apartment.title %></p>****
Error: Cannot GET /apartments/7
I am still receiving the above error.
that error means you don't have a get route in your controller that has a url pattern of /:id
I have a get route with an id. Maybe i am missing what you are saying
router.get('/:id', (req, res) => {
db.apartment.findOne({
// include: [db.tag],
where: { id: req.params.id }
}).then((apartment) => {
res.render('apartments/:id', { apartment: apartment })
}).catch((error) => {
console.log(error)
res.send('display apartments')
})
})
Solution: <a href="/apartment/<%= apartment.id %>">
The solution was to remove the s in index.ejs from apartments in <a href="/apartments/<%= apartment.id %>">
I get this message: Cannot GET /apartments/1 I'm wondering if its a url route issue. Also my UPDATE crashes my app. For now I have it commented out. Is it too late to start over??? I haven't been able to solve any issues on my own. I don't think its clicking and the more things i read/research is making me feel more lost