I have a nodejs app and I am trying to pass a value called membership to a page. I initialize it and try to update its value in a function but the output doesn't change. It still outputs 0. Please I need help
app.get("/",(req,res)=>{
var membershipStrength = 0;
memberData.findAll()
.then(members =>{
// console.log(members.length);
membershipStrength = members.length;
console.log(membershipStrength);
})
.catch(err => {
console.log("Error fetching members data: ", err);
});
console.log(membershipStrength);
return res.render("index",
{
page: "Admin",
membershipStrength: membershipStrength,
// tableData : global.dataOut
}
);
});