Handle url parameters in an HTTP endpoint

Problem

You want to create a single HTTP endpoint that can handle requests where parts of the path are set per-request.

For example, a single endpoint that can handle requests to both:

http://example.com/hello-param/Nick
http://example.com/hello-param/Dave

Solution

Use named path parameters in your HTTP In node’s URL property and then access the specific value provided in a request using the msg.req.params property of the message.

Flow

Example

Discussion

Named path parameters in the URL property can be used to identify parts of the path that can vary between requests.

The msg.req.params property is an object of key/value pairs for each path parameter.

In the above example, the node is configured with a URL of /hello-params/:name, so a request to /hello-param/Nick results in the msg.req.params property containing:

Last updated

Was this helpful?