I’m making an ejs app where it returns a randomized gif from a database. I have a page that successfully confirms you uploaded a gif (images page.ejs) but in my home.ejs file where it renders from the /random path I get an error where it can’t find the property of ‘img’ even though it’s in my schema. Attached is a link to the GitHub page of a zip file of what I have so far. Link
`app. get('/random', async (req, res) =>{
const findGif = await gifFinder();
res.render('home', {findGif})
});
const gifFinder = async (req, res) => {
const foundGif = imgModel.count().exec(function (err, count) {
// Get a random entry
const random = Math.floor(Math.random() * count)
// Again query all users but only fetch one offset by our random #
imgModel.findOne().skip(random).exec(
function (err, result) {
// Tada! random user
// console.log(result)
})
});
//return the found gif
return foundGif;
};`