title: Populate data from mysql to ejs
body: <p><a href="https://github.com/AEkman/Quiz" rel="nofollow noreferrer">Link to github https://github.com/AEkman/Quiz</a></p>
  
  <p>I'm trying to get data from mysql database and print to a html table using EJS.</p>
  
  <p>This is my function call from database.js:</p>
  
  <pre><code>    this.getUsers = function (res) {
      connection.acquire(function (err, con) {
          con.query('SELECT * FROM user', function (err, rows, result) {
              con.release();
              if(err) {
                  console.log(err);
              } else {
                  obj = JSON.parse(JSON.stringify(rows));
                  console.log(obj);
              }
          });
      });
  };
  };
  </code></pre>
  
  <p>This is my route in app.js</p>
  
  <pre><code>app.get('/settings', function(req, res) {
  var obj = databaseFunctions.getUsers(res);
  res.render('settings', {
      obj:obj,
      title: 'Settings',
      classname: 'settings'
  });
  });
  </code></pre>
  
  <p>This is my EJS code:</p>
  
  <pre><code>&lt;% print.forEach(function(users) { %&gt;
  &lt;tr&gt;
      &lt;td&gt;&lt;%= users.mail %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= users.name %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= users.password %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= users.groups %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= users.accountLevel %&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;% }); %&gt;
  </code></pre>
  
  <p>If i console.log(obj) i get:</p>
  
  <pre><code>[ { mail: 'info@andreasekman.com',
  name: 'test',
  password: '1234',
  groups: 'java2',
  accountLevel: 'User' },
  { mail: 'xtironman@hotmail.com',
  name: 'ace',
  password: 'ace',
  groups: 'java2',
  accountLevel: 'User' } ]
  </code></pre>
  
  <p>When i try to run /settings i get the following:</p>
  
  <pre><code>    TypeError: C:\Users\Andreas\Documents\GitHub\Quiz\views\settings.ejs:15
     13|         &lt;h1&gt;Settings&lt;/h1&gt; 
     14|         &lt;% include partials/template/createuser.ejs %&gt; 
  &gt;&gt; 15|         &lt;% include partials/template/viewusers.ejs %&gt; 
     16|     &lt;/div&gt;&lt;!-- row --&gt; 
     17|     &lt;div class="content"&gt;&lt;/div&gt; 
     18|     &lt;% include partials/template/footer.ejs %&gt; 
  
  esc is not a function
     at rethrow (C:\Users\Andreas\Documents\GitHub\Quiz\node_modules\ejs\lib\ejs.js:285:18)
     at eval (eval at compile (C:\Users\Andreas\Documents\GitHub\Quiz\node_modules\ejs\lib\ejs.js:524:12), &lt;anonymous&gt;:85:9)
     at eval (eval at compile (C:\Users\Andreas\Documents\GitHub\Quiz\node_modules\ejs\lib\ejs.js:524:12), &lt;anonymous&gt;:87:10)
     at returnedFn (C:\Users\Andreas\Documents\GitHub\Quiz\node_modules\ejs\lib\ejs.js:555:17)
     at tryHandleCache (C:\Users\Andreas\Documents\GitHub\Quiz\node_modules\ejs\lib\ejs.js:203:34)
     at View.exports.renderFile [as engine] (C:\Users\Andreas\Documents\GitHub\Quiz\node_modules\ejs\lib\ejs.js:412:10)
     at View.render (C:\Users\Andreas\Documents\GitHub\Quiz\node_modules\express\lib\view.js:126:8)
     at tryRender (C:\Users\Andreas\Documents\GitHub\Quiz\node_modules\express\lib\application.js:639:10)
     at EventEmitter.render (C:\Users\Andreas\Documents\GitHub\Quiz\node_modules\express\lib\application.js:591:3)
     at ServerResponse.render (C:\Users\Andreas\Documents\GitHub\Quiz\node_modules\express\lib\response.js:960:7)
  </code></pre>
  
  <p>What am I doing wrong?</p>