Home/Tutorials/Express/Route Params and Query

0 of 3 saved

Express5 min read

Route Params and Query

Read this chapter, write the program on this page, then pass a short check to open the next one.

Dynamic URLs.

Route Params and Query

Use /users/:id for path params (req.params). Use ?page=1 for query strings (req.query). Validate both.

  • Params are strings โ€” coerce numbers carefully.
  • Never trust client input.
  • 404 when a resource is missing.
const params = { id: "42" };
console.log(params.id);

After you read this chapter, use Write (when available) and Quiz on this page to lock it in.