Updating the home controller

If you take a look at our current home controller (controllers/home.js), you can see that the index function barely has any code in it whatsoever:

res.render('index');

The first thing we want to do is build a basic View model using sample data so that we can see our View model at work. Replace that single res.render call with the following updated code:

const ViewModel = {        images: [            images: [{                uniqueId: 1,                title: 'Sample Image 1',                description: '',                filename: 'sample1.jpg',                Views: 0,                likes: 0,                timestamp: Date.now()            }, {                uniqueId: 2,                title: 'Sample Image 2',                description: '',                filename: 'sample2.jpg',                Views: 0,                likes: 0,                timestamp: Date.now()            }, {                uniqueId: 3,                title: 'Sample Image 3',                description: '', filename: 'sample3.jpg', ...

Get Web Development with MongoDB and Node - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.