title: Handlebars: Access has been denied to resolve the property "from" because it is not an "own property" of its parent
body: <p>I am using a Nodejs backend with server-side rendering using handlebars.
  After reading a <code>doc</code> array of objects from handlebars, which contains key "content" and "from".
  However when I try to use <code>#each</code> to loop through the array of objects,
  the error "Handlebars: Access has been denied to resolve the property "from" because it is not an "own property" of its parent" appears.</p>
  
  <p>I've tried to console.log() the data that I've fetched in the doc array and everything seems fine.  </p>
  
  <p>For some perspective, this is the mongoose query,<br>
  I've added the object doc as a key inside the res.render arguments.
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>Confession.find()
    .sort({date: -1})
    .then(function(doc){
      for(var i=0; i &lt; doc.length; i++){
        //Check whether sender is anonymous
        if (doc[i].from === "" || doc[i].from == null){
          doc[i].from = "Anonymous";
        }
  
        //Add an extra JSON Field for formatted date
        doc[i].formattedDate = formatTime(doc[i].date);
      }
      res.render('index', {title: 'Confession Box', success:req.session.success, errors: req.session.errors, confession: doc});
      req.session.errors = null;
      req.session.success = null;
    });</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is the portion of .hbs file I am trying to loop through:
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code> {{#each confession}}
      &lt;div class="uk-card uk-card-default uk-card-body uk-margin uk-align-center uk-width-1-2@m" &gt;
          &lt;div class="uk-text-bold"&gt;Message: &lt;/div&gt;
          &lt;div&gt;{{this.content}}&lt;/div&gt;
          &lt;div&gt;From: {{this.from}}&lt;/div&gt;
          &lt;div&gt;Posted: {{this.formattedDate}}&lt;/div&gt;
      &lt;/div&gt;
      {{/each}}</code></pre>
  </div>
  </div>
  </p>