hi m trying to get the data from database (MongoDB) using ejs as view-engine, but it shows error:

> 
> ReferenceError: D:\nodejs\crud\views\employee\list.ejs:21,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 
> 
> 
> 

list.ejs:

```
<tbody>
<% employees.forEach(function (employees) { %>
<tr>
  <td><%= employees.fullname %></td>
  <td><%= employees.email %></td>
  <td><%= employees.mobile %></td>
  <td><%= employees.city %></td>
  <td>
    <a href="/show" class="btn btn-outline-info my-2 my-sm-0">Show</a>
    <a href="/edit" class="btn btn-outline-warning my-2 my-sm-0">Edit</a>
    <a href="" class="btn btn-outline-danger my-2 my-sm-0">Delete</a>
  </td>
</tr>
<% }) %>

```

complete error code:

```
  ReferenceError: D:\nodejs\crud\views\employee\list.ejs:21
  19|   </thead>
  20|   <tbody>
  >>   21|     <% employees.forEach(function (employees) { %>
       22|     <tr>
       23|       <td><%= employees.fullname %></td>
       24|       <td><%= employees.email %></td>

  employees is not defined
      at eval (eval at compile 
  (D:\nodejs\crud\node_modules\ejs\lib\ejs.js:633:12), <anonymous>:11:8)
  at returnedFn (D:\nodejs\crud\node_modules\ejs\lib\ejs.js:668:17)
  at tryHandleCache (D:\nodejs\crud\node_modules\ejs\lib\ejs.js:254:36)
  at View.exports.renderFile [as engine]       
  (D:\nodejs\crud\node_modules\ejs\lib\ejs.js:485:10)
  at View.render (D:\nodejs\crud\node_modules\express\lib\view.js:135:8)
  at tryRender 
  (D:\nodejs\crud\node_modules\express\lib\application.js:640:10)
  at Function.render 
  (D:\nodejs\crud\node_modules\express\lib\application.js:592:3)
  at ServerResponse.render 
  (D:\nodejs\crud\node_modules\express\lib\response.js:1012:7)
  at ServerResponse.res.render (D:\nodejs\crud\node_modules\express-ejs-
  layouts\lib\express-layouts.js:77:18)
 at Employee.find (D:\nodejs\crud\controllers\employeeController.js:32:8)
 at D:\nodejs\crud\node_modules\mongoose\lib\model.js:4581:16
 at D:\nodejs\crud\node_modules\mongoose\lib\query.js:4315:12
 at process.nextTick 
  (D:\nodejs\crud\node_modules\mongoose\lib\helpers\query\completeMany.js:35:39)
at process._tickCallback (internal/process/next_tick.js:61:11)

```

server.js:

```
  require('./models/db');
  require('./models/employee.model');

  const express = require('express');
  const mongoose = require('mongoose');
  const expressLayouts = require('express-ejs-layouts');
  const bodyParser = require('body-parser');
  const path = require('path');

  const employeeController = require('./controllers/employeeController');

  var app = express();

  app.use(bodyParser.urlencoded({ extended: true }))
  app.use(bodyParser.json())

  //EJS
  app.use(expressLayouts);
  app.set('view engine','ejs');

  app.listen(3000, () => {
      console.log('Express server started at port : 3000');
  });

  app.use('/employee', employeeController);

```

employeeController.js:

```
  const express = require('express');
  var router = express.Router();
  const mongoose = require('mongoose');
  const Employee = mongoose.model('Employee');

  router.get('/',(req, res) => {
res.render("employee/addOrEdit");
  });

  router.post('/',(req, res) => {
insertRecord(req, res);
  });

  function insertRecord(req, res) {
      var employee = new Employee();
      employee.fullName = req.body.fullname;
      employee.email = req.body.email;
      employee.mobile = req.body.mobile;
      employee.city = req.body.city;
      employee.save((err, doc) => {
    if (!err)
      res.redirect('employee/list');
    else {
        console.log('Error during record insertions : ' + err);
          }
      });
  }

  router.get('/list', (req, res) => {
      Employee.find((err, docs) => {
    if (!err) {
        res.render("employee/list", {
            list: docs
        });
    } else {
        console.log('Error in retrieving employee list :' + err);
    }
});
  });

  module.exports = router;

```