LOGBOOK

HELP

Quiz Entry - updated: 2026.06.20

How do you access query parameters in Express?

Express parses the query string into the req.query object, so req.query.first gives you each parameter's value.

// Request: GET /customer?first=John&last=Doe

router.get('/customer', function(req, res) {
    // Check if parameter exists
    // false
    let hasName = 'name' in req.query;

    // Get parameter values
    // 'John'
    let first = req.query.first;
    // 'Doe'
    let last = req.query.last;

    res.send(`Hello ${first} ${last}`);
});

Key points:

  • req.query is an object with all query parameters
  • Use 'key' in req.query to check if a parameter exists
  • Use req.query.key or req.query['key'] to get the value
  • Missing parameters return undefined

Always validate: Never trust query parameters - they come from the user!

From Quiz: WEBT / Backend Development | Updated: Jun 20, 2026