Hello,
I have this code which I think would activate my partial in handlebars.
app.get("/api/project/:id", function (req, res) {
db.Project.findAll({
where: {
CarId: req.params.id,
},
}).then(function (dbProjects) {
if (dbProjects[0]) {
const projects = [];
dbProjects.forEach((project) => {
projects.push(project.dataValues);
});
res.render("member", { nocar: "You have not added any cars" })
} else {
res.json([]);
}
});
});
It seems as though once it has been rendered the first time, I can’t seem to pass any other additional objects to handlebars. I have this other render function that also sends and updates the handlebar.js just fine. But it seems when I call the api end point "/api/project/:id" I can’t re-render the templatate with the new info. My question is how can I update handlebars with the new info after calling that API end point?
This is the endpoint that updates handlebars as it should
app.get("/members", isAuthenticated, function (req, res) {
db.Car.findAll({
where: {
userId: req.user.id,
},
}).then(function (dbCar) {
if (dbCar[0]) {
res.render("member", dbCar[0].dataValues);
} else {
res.render("member", { nocar: "You have not added any cars" });
}
});
});
};