Message from JavaScript discussions

June 2019

— Hi guys, i need help to render my variable to ejs, i end up getting "fail is not defined"


app.get('/profile', function (req, res, next) {
req.getConnection(function (err, conn) {
conn.query("SELECT count(*) as total from transaction ",
function (err, fail ) {
if(err) throw err;
res.render('/profile', {

— Where i am trying to render fail

— <span class="h2 font-weight-bold mb-0"><%= fail%></span>

— What could i be doing wrong?😢

— Does '/profile' exist?

— Shouldn't it be just 'profile'

— Yes it does

— Still even after changing to profile

— \views\profile.ejs:207
205| <div class="col">
206| <h5 class="card-title text-uppercase text-muted mb-0">Failed</h5>
>> 207| <span class="h2 font-weight-bold mb-0"><%= fail%></span>
208| </div>
209| <!--<div class="col-auto">-->
210| <!--<div class="icon icon-shape bg-yellow text-white rounded-circle shadow">-->

fail is not defined

Message permanent page

— Try console.logging it here before rendering?

— Maybe it literally is undefined