title: How to fix ' type error cannot read property 0 of undefined '?
body: <p>I can't get <code>row[].column_name</code> in my .hbs file althougth when I <code>console.log(row)</code> it shows the result.</p>
  
  <p>The error is the following: </p>
  
  <blockquote>
    <p>TypeError: Cannot read property 0 of undefined</p>
  </blockquote>
  
  <pre><code>router.get('/:id/baiviet', (req, res) =&gt; {
    var id = req.params.id;
    var p = baivietModel.allByCat(id);
    var q = chuyenmuc.singel(id); // singel(id) return a promise
    var row;
  
    q.then(rows =&gt; {
      row = rows;
    });
  
    p.then(rows =&gt; {
      for (const cm of res.locals.lcChuyenmuc) {
        if (cm.ID == +id) {
          cm.isActive = true;
        }
      }
      res.render('vwBaiviet/byCat', {
        baiviet: rows,
        CM: row[0]
      });
    }).catch(err =&gt; {
      console.log(err);
    });
  });
  </code></pre>
  
  <p>My .hbs file:</p>
  
  <pre><code>{{this.CM.Name}}
  </code></pre>