Sequelize, Express.js, & Handlebars.js being turds?
Cory Allen
Posted on September 13, 2022
My brain is sizzling, either I am overlooking a tiny detail or this is supposed to work and doesn't for whatever reason. Just trying to render by findAll() query to the page using handlebars. Here's what I have.
Controller:
const library = require('../models/Library');
exports.manage_library = (req, res) => {
Library.findAll()
.then(function(data) {
res.render('manage-library', {
title: "Manage Website",
user: req.user,
data: data
})
});
}
View:
{{#each data}}
<div class="list-group-item d-flex justify-content-between">
<div><strong>{{this.name}}</strong></div>
<div>
<a href="/edit-category/{{this.id}}" class="btn btn-sm btn-warning"><i class="bi bi-pencil"></i></a>
<a href="/delete-category/{{this.id}}" class="btn btn-sm btn-danger"><i class="bi bi-trash3"></i></a>
</div>
</div>
{{/each}}
I am new to Node & Express, this is my first serious project so forgive me if I am overlooking something minor. Basically, the above code renders the appripriate amount of list-group-item
but I cannot display actual data within the list-group-item
.
What the glorp am I doing wrong?! 👽
💖 💪 🙅 🚩
Cory Allen
Posted on September 13, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.