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)
![Maria Te](https://secure.gravatar.com/avatar/bf760105e554a2851885da254ccb905a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Maria Te
8,521 PointsI have an error when I type localhost:4000/cards:0
I am following the video but my code doesn't work
routes/cards.pug
const express = require('express');
const router = express.Router();
const { data } = require('../data/flashcard.json');
const { cards } = data;
router.get('/:id', (req, res) => {
res.render('cards', {
prompt: cards[req.params.id].question,
hint: cards[req.params.id].hint,
answer: cards[req.params.id]
});
});
router.post('/:id', (req, res) => {
res.render('cards', {
prompt: cards[req.params.id].question,
hint: cards[req.params.id].hint,
answer: cards[req.params.id]
});
});
views/cards.pug
extends layout.pug
block content
section#content
form(action="/cards", method="post")
h3= prompt
if hint
p
i Hint: #{hint}
h3
i Answer: #{answer}
button(type="submit") Next
2 Answers
![Maria Te](https://secure.gravatar.com/avatar/bf760105e554a2851885da254ccb905a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Maria Te
8,521 PointsOh wait, now I have it. You have to do localhost:4000/cards/0
![Maria Te](https://secure.gravatar.com/avatar/bf760105e554a2851885da254ccb905a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Maria Te
8,521 Pointsdata/flashcard.json
{
"data": {
"title": "Animal FlashCards",
"cards": [
{
"question": "What's the smallest animal on Earth?",
"hint": "It lives in the ocean",
"answer": "Water Bear"
},
{
"question": "How many legs does a milipede have?",
"hint": "Number from 100 - 1000",
"answer": "400"
},
{
"question": "How big is a baby kangaroo?",
"hint": "Less than 1 foot",
"answer": "2 cm"
},
{
"question": "What's the loudest animal in the world?",
"hint": "It can't walk or fly",
"answer": "Sperm Whale"
},
{
"question": "How fast can a cheetah run?",
"hint": "Number from 10 - 200",
"answer": "70 mph"
},
{
"question": "What's the longest living animal?",
"hint": "It's a warm-blooded mammal",
"answer": "Bowhead Whale"
},
{
"question": "How many times can a woodpecker peck per sec?",
"hint": "Number from 1 - 50",
"answer": "20 times"
},
{
"question": "How many years old can a mouse be?",
"hint": "Number from 1 - 30",
"answer": "2 years"
},
{
"question": "Which animal is immortal?",
"hint": "Turtles eat them",
"answer": "Immortal Jellyfish"
}
]
}
}