1. app.js

const allController = require('./homeController')
app.get('/show', allController.getAllUser)

2. homeController.js

const user_model = require('./user_model') // include user_model.jsexports.getAllUser = async (req, res, next) => {
let user_data = await user_model.find()
res.render('show',{user_data})
}

3. Create Show.ejs file:

vim show.ejsblog_expressjs/views/show.ejs<table class="table">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Description</th>
<th>Action</th>
</tr>
</thead>
<tbody>

<% for(let p of user_data) { %>
<tr>
<th><%= p.id %></th>
<td><%= p.title %></td>
<td><%= p.description %></td>
<td>
<a class="btn btn-md btn-success">Edit</a>
<a class="btn btn-md btn-danger">Delete</a>
</td>
</tr>
<% } %></tbody>
</table>

--

--