Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Express Basics Parameters, Query Strings, and Modularizing Routes Card Template

Jonathan Drake
seal-mask
.a{fill-rule:evenodd;}techdegree
Jonathan Drake
Full Stack JavaScript Techdegree Student 9,050 Points

Text not displaying...

I've copied and pasted Andrew's code (which matched mine but I copied and pasted to make sure) and the 'text' of the question is not displaying. I changed the variable in the card.pug file from 'prompt' to 'text' to match the code in the cards.js file but the only thing that display is the hint. Here's the code from the cards.js file:

const express = require('express'); const router = express.Router(); const { data } = require('../data/flashcardData.json'); const { cards } = data;

router.get('/:id', (req, res) => { const { side } = req.query; const { id } = req.params; const text = cards[id][side]; const { hint } = cards[id]; const templateData = { text, hint };

res.render('card', templateData);

})

module.exports = router;

And the code from the card.pug:

extends layout.pug

block content section#content h2= prompt if hint p i Hint: #{hint}

1 Answer

Jonathan Drake
seal-mask
.a{fill-rule:evenodd;}techdegree
Jonathan Drake
Full Stack JavaScript Techdegree Student 9,050 Points

Nevermind! I wasn't using the query string in the url... it's always something simple. In woodworking we say "measure twice cut once"...same idea applies here