Applying Parameters in Routes

As you begin implementing routes, you will quickly see that for complex systems, the number of routes can get out of hand. To reduce the number of routes, you can implement parameters within the URL. You can use parameters to use the same route for similar requests by providing unique values for different requests that define how your application handles requests and builds responses.

For example, you would not have a separate route for every user or product in your system. Instead, you would pass in a user ID or product ID as a parameter to one route, and the server code would use that ID to determine which user or product to use. There are four main methods for implementing parameters in a route:

Query strings: ...

Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.