"TypeError: Cannot assign to read only property" when rendering Expressjs view
<p>I am building an app in node.js and encountered an error when I tried to send data from my server to my view:</p>

<pre><code>module.exports = function (req, res) {

var cookie = parseCookie.parseCookie(req.headers.cookie);

user.returnUser(cookie, function(result) {

    var context = result[0].first_name;
    console.log(context); //console logs properly
    res.render('../views/home', context); //errors out at 'context'
});
};
</code></pre>

<p>The error returned is:</p>

<pre><code>Unhandled rejection TypeError: Cannot assign to read only property '_locals' of Josh
at ServerResponse.render (/Users/tinzors/Documents/portal/node_modules/express/lib/response.js:952:16)
at /Users/tinzors/Documents/portal/controllers/home.js:27:7
at /Users/tinzors/Documents/portal/methods/returnUser.js:8:5
at tryCatcher (/Users/tinzors/Documents/portal/node_modules/knex/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/Users/tinzors/Documents/portal/node_modules/knex/node_modules/bluebird/js/main/promise.js:507:31)
at Promise._settlePromiseAt (/Users/tinzors/Documents/portal/node_modules/knex/node_modules/bluebird/js/main/promise.js:581:18)
at Promise._settlePromises (/Users/tinzors/Documents/portal/node_modules/knex/node_modules/bluebird/js/main/promise.js:697:14)
at Async._drainQueue (/Users/tinzors/Documents/portal/node_modules/knex/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/Users/tinzors/Documents/portal/node_modules/knex/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/tinzors/Documents/portal/node_modules/knex/node_modules/bluebird/js/main/async.js:15:14)
at processImmediate [as _immediateCallback] (timers.js:374:17)
</code></pre>

<p>My view:</p>

<pre><code>&lt;!DOCTYPE HTML&gt;
&lt;html&gt;

{{&gt; header}}
&lt;script type="text/javascript" src="/js/home.js"&gt;&lt;/script&gt;

    &lt;div class="container"&gt;
      &lt;h1&gt;Welcome home, {{first_name}}.&lt;/h1&gt;
    &lt;/div&gt;
&lt;/html&gt;
</code></pre>

<p>I'm not sure if it helps, but <code>user.returnUser</code> calls a method that returns data from a DB query.</p>

<p>Can someone help?</p>

<p>Thanks in advance!!</p>