Reading image files asynchronously and displaying them on the page
Don't use callbacks, it's hard to read and maintain, the fs.readdir function will return a promise if you didn't provide a callback function.
Use arrow functions when you could.
Respond with an error instead of throwing (unless you have a catch wrapper middleware).
Use property shorthands.
You forgot req and res.


Try this:

const express = require('express');
const router = express.Router();
const fs = require('fs');

router.get('/', async (req, res) =&gt; { 
  try {
    const files = await fs.readdir('./assets/images/')
    res.render({ files })  // notice the property shorthand
  } catch (error) {
    res.status(404).json({ error })
  }
});

module.exports = router;