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

Bartlomiej Figatowski
5,843 Pointsdifference between req.params and req.query.
Could someone explain what the difference is between req. params and req. query and when it is used. Maybe an example.
1 Answer

Clayton Perszyk
Treehouse Moderator 48,863 Pointsgiven this route: hello/:param1 and given the following URL: hello/world?id=123&name=joe
req.params will return:
{ param1: 'world' }
req.query will return:
{ id: 123, name: 'joe' }
so, params are before the ? and the keys/values after will be a part of the query object.
NOTE: everything after the ? is called the query string, hence req.query.
Bartlomiej Figatowski
5,843 PointsBartlomiej Figatowski
5,843 PointsThank you for your answer. I am currently working on my portfolio. I would like to do a search box and filter for my posts or would you like a hint on how to do it. This is my github code https://github.com/bartekfigat/portfolio-website-front-end-and-back-end?files=1. Thanks Clayton