I am trying to write an api with the http in node. I want to use path parameters so that I can have an api path that is - for instance - in the form api/:color/:shape
Is it possible to have more than one path parameter on the http in node? I can do it with query parameters, but path would be nicer for others in the team.
When I try it, it's easy to do the api/:color part, but as soon as I try anything with a second path parameter I just get no response at all. And nothing even in the debug node in my node-red environment.
Under the hood, this is just an express endpoint so api/:color/:shape should work - so long as the URL has both parts.
But if you want it shape to be optional (omitted from the URL), you need to add a question mark api/:color/:shape?
Note: this matcher api/:color/:shape? leaves little room for other more specific routes (basically it would intercept api/user/1 - clearly not intended.
I would recommend you at minimum specify a version and 1 fixed part to the path (to permit other future routes) e.g. api/v1/something/:color/:shape?
Yeah - I thought it should be straightforward and indeed - all this is downstream of a v1/specificfunction/ path in the APIs.
So it's really /v1/checkshape/:color/:shape
But I still don't get it to work. All I'm doing is setting msg.payload to be msg.req.params and passing it back in the http response.
If I have one path, no problem at all. Soon as I add that second path? No response. Not even a debug message. I'm sending the messages from postman mostly, but I tried from command line (with Curl) as well.