Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Brian Patterson](https://uploads.teamtreehouse.com/production/profile-photos/3947332/micro_image2.jpg)
Brian Patterson
19,588 Pointsgetting this error RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined when going to cards.
I am running the following code in the cards.js file.
const express = require('express');
const router = express.Router();
const { data } = require('../data/flashcardData.json');
//the above is the same as:
//const data = require('../data/flashcardData.json').data;
const cards = data.cards;
router.get('/', (req, res) => {
res.render('card', {
prompt: cards[0].question,
hint: cards[0].hint
});
});
module.exports = router;
and I am getting the above error. What does it mean? Below is it the error code in the console.
at ServerResponse.writeHead (_http_server.js:197:11)
at ServerResponse._implicitHeader (_http_server.js:188:8)
at write_ (_http_outgoing.js:644:9)
at ServerResponse.end (_http_outgoing.js:767:5)
at ServerResponse.send (/Users/briankaty1/Dropbox/JavaScript/flashcards/node_modules/express/lib/response.js:221:10)
at done (/Users/briankaty1/Dropbox/JavaScript/flashcards/node_modules/express/lib/response.js:1004:10)
at Object.exports.renderFile (/Users/briankaty1/Dropbox/JavaScript/flashcards/node_modules/pug/lib/index.js:422:12)
at View.exports.__express [as engine] (/Users/briankaty1/Dropbox/JavaScript/flashcards/node_modules/pug/lib/index.js:465:11)
at View.render (/Users/briankaty1/Dropbox/JavaScript/flashcards/node_modules/express/lib/view.js:135:8)
at tryRender (/Users/briankaty1/Dropbox/JavaScript/flashcards/node_modules/express/lib/application.js:640:10)
2 Answers
![Alina Bylkova](https://uploads.teamtreehouse.com/production/profile-photos/11520259/micro_47.jpg)
Alina Bylkova
6,862 PointsCheck your pug file for example if you still pass all the required variables, for example
if you comment out colors
variable, pug cannot create list of colors and in my case failed with ERR_HTTP_INVALID_STATUS_CODE
res.render('card', {
prompt: "Who is buried in Grant's tomb?",
hint: 'Think about whose tomb it is.',
//colors,
});
extends layout.pug
block content
section#content
// ul
// each color in colors
// li= color
h2= prompt
if hint
p
i Hint: #{hint}
else
p (There is no hint.)
![Michael Kilcorse](https://uploads.teamtreehouse.com/production/profile-photos/10707501/micro_me.jpg)
Michael Kilcorse
Full Stack JavaScript Techdegree Graduate 17,643 PointsWhat URL are you typing into your browser? I was getting this error because I accidentally typed localhost:3000/cards/id into my browser instead of localhost:3000/cards/1
But yeah, I would check your URL path
![Michael Cook](https://uploads.teamtreehouse.com/production/profile-photos/10325482/micro_10441420_10152452040502048_3507177777575354946_n.jpg)
Michael Cook
Full Stack JavaScript Techdegree Graduate 28,975 PointsI am getting the same error but my url is correct. It would be really nice if you responded saying how you fixed it for the benefit of others.