Friday 29 May 2020

Having trouble with passing data from database to handlebars view

I'm passing some data from a postgres database with sequelize to my handlebars view. The data is passed but I'm not able to display it as I think I'm supposed to be able to do.This should be all the relevant code, if anything else is needed please let me know.Router code:router.get('/:name', (req, res) => { var userName = req.params.name; User.findOne({ where: { name: userName } }) .then(user => { res.render('user', { user }); }) .catch(err => console.log(err)); }); Handlebars view:This is where I'm having problems, this code:results in an empty paragraph. Logging it with outputs undefined.​This code however: results in 6 paragraphs, the last 4 of which are empty. Logging it results in it outputting 6 times, the first two are the name in the databaseTest Name // correct result Test Name // again, correct result undefined undefined undefined undefined ​The console displays no errors.

Submitted May 29, 2020 at 03:36PM by Rayeth_

No comments:

Post a Comment