Closed devinrbopp closed 2 years ago
Is there any way to use a url parameter? i.e. is the browser showing a page that could be specifically dedicated to that user's info?
I edited it a bit! The following controller edit worked:
// GET display all recipients
router.get('/', isLoggedIn, (req,res) => {
db.recipient.findAll({where: {userId: req.user.dataValues.id}})
.then((recipients) => {
res.render('recipients/index', {recipients: recipients })
}).catch(error => {
console.error()
})
// res.render('recipients/recipients')
})
So now the index page will only display recipients associated with the currently logged in user.
I am trying to filter a table to only display items with the current user's id.
This returns the error
ReferenceError: currentUser is not defined
.I can't figure out how to access the id of the user in Javascript, but I figured out how to do so in ejs. What is the best way to access the current user's id (from the users table)?