title: getting RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined in express app
body: <p>I am getting the above error when running the following code in my express app.  When I go to localhost:3000/cards.</p>
  
  <p>This is in my cards.js file.</p>
  
  <pre><code>const express = require('express');
  const router = express.Router();
  const { data } = require('../data/flashcardData.json');
  const { cards } = data;
  
  router.get('/', (req, res) =&gt; {
  res.render('card', {
  prompt: cards[0].question,
  hint: cards[0].hint
   });
  });
  
  module.exports = router;
  </code></pre>
  
  <p>This is the code in my app.js file.</p>
  
  <pre><code>const express = require('express');
  const bodyParser = require('body-parser');
  const cookieParser = require('cookie-parser');
  
  const app = express();
  
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  
   app.set('view engine', 'pug');
  
   const mainRoutes = require('./routes');
   const cardRoutes = require('./routes/cards');
  
   app.use(mainRoutes);
   app.use('/cards', cardRoutes);
  
   app.use((req, res, next) =&gt; {
   const err = new Error('Not Found');
   err.status = 404;
   next(err);
   });
  
  app.use((err, req, res, next) =&gt; {
  res.locals.error = err;
  res.status(err.status);
  res.render('error');
  });
  
   app.listen(3000, () =&gt; {
   console.log('The application is running on localhost:3000!');
   });
  </code></pre>
  
  <p>Any help would be appreciated. Basically, I am trying to incorporate a json file into the express app and it is coming up with this error.</p>