Hello,
In a terminal I run the following command:
curl -X GET http://localhost:1880/zonex/?x=3&y=4&radius=5
An HttpIn node is triggered in my flow. It is connected to function node which must get the request parameters and put them in the msg.payload.
Then a debug node should print :
{"x":"3", "y":"4","radius":"5"}
The result I get is x=3 and y and radius are undefined.
{"x":"3", y=undefined, radius = undefined}
Can you help me please ? don't hesitate to ask me to rephrase or complete my post.
Here is the flow's code:
[
{
"id": "fd3c017bbed97322",
"type": "tab",
"label": "Turbopi",
"disabled": false,
"info": "",
"env": []
},
{
"id": "http_in",
"type": "http in",
"z": "fd3c017bbed97322",
"name": "",
"url": "/zonex/",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 310,
"y": 500,
"wires": [
[
"function_node",
"045e338e2dafe6ad"
]
]
},
{
"id": "function_node",
"type": "function",
"z": "fd3c017bbed97322",
"name": "Extract Parameters",
"func": "// Extract query parameters\nvar x = msg.req.query.x;\nvar y = msg.req.query.y;\nvar radius = msg.req.query.radius;\n\n// Create a new message payload\nmsg.payload = {\n x: x,\n y: y,\n radius: radius\n};\n\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 570,
"y": 500,
"wires": [
[
"debug_node"
]
]
},
{
"id": "debug_node",
"type": "debug",
"z": "fd3c017bbed97322",
"name": "Print Parameters",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 840,
"y": 500,
"wires": []
},
{
"id": "045e338e2dafe6ad",
"type": "http response",
"z": "fd3c017bbed97322",
"name": "",
"statusCode": "",
"headers": {},
"x": 750,
"y": 400,
"wires": []
}
]