title: Passing the value from controller to the template engine - MVC and EJS
body: <p>I am trying to iterate the list of user and return it to the template engine. For some reason I got an error that object is not iterable.</p>
  
  <p>This is my controller: </p>
  
  <p><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>const Bug = require('../models/bugs');
  const bodyParser = require('body-parser');
  const User = require('../models/user');
  
  
  
  exports.getAddBug = (req, res, next) =&gt;{
      res.render('add-bug', {
          pageTitle: 'Add a bug',
          path: '/add-bug',
          user: req.session.user.fullName,
          allUsers : User.find()
      }
  
  )};</code></pre>
  </div>
  </div>
  </p>
  
  <p>There is a EJS file to which all the user values shall be passed: </p>
  
  <p><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>&lt;ion-item&gt;
                              &lt;% for (let user of allUsers) { %&gt;
                              &lt;ion-label&gt;Assigned to&lt;/ion-label&gt;
                              &lt;ion-select name="assignedTo" placeholder="Select One"&gt;
                                  &lt;ion-select-option selected value="&lt;%= user.fullName%&gt;"&gt;&lt;%= user.fullName%&gt;&lt;/ion-select-option&gt;
                              &lt;/ion-select&gt;
                              &lt;% } %&gt;
                          &lt;/ion-item&gt;</code></pre>
  </div>
  </div>
  </p>