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 trialGabe Orlandi
6,712 PointsClarification on url definition
In this lesson we have the following async/await (req, res)
// SEND a GET request to/quotes to READ a list of quotes app.get('/quotes', async(req, res) => { const quotes = await records.getQuotes(); res.json(quotes); });
// Send a GET request to/quotes/:id READ(view) a quote app.get('/quote/:id', async(req, res) => { const quote = await records.getQuote(req.params.id); // req.params.id is the code to get the id of an item res.json(quote);
IS THERE A REASON WHY WE DIDN'T KEEP THE SAME URL '/quotes/:id' ? Since we are just looking for an element within the quotes list, why did she switch to quote instead?
1 Answer
Gabe Orlandi
6,712 PointsI tested by maintaining the same url and just adding the id number and it works. I think we can assume she gave the url the same name of the const for simplicity reasons