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...