Hi, im trying to build a simple flow:
- An AWS Lambda Function that just return a value
- An input node that on trigger execute a Function Node that use AWS SDK in Js to simply invoke my function and save the message in msg.payload
- A Debug Node that should show the message, but slimply show "UNDEFINED"
As you can see in the Function node I save the message in the msg.payload but the Debug Node don't show it, but trying to console.log it I can read the result in the console without problem? Why I'm having this problem?
[
{
"id": "f6f2187d.f17ca8",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "e72d8d71.b49a8",
"type": "debug",
"z": "f6f2187d.f17ca8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 730,
"y": 200,
"wires": []
},
{
"id": "7690d6ae.421348",
"type": "inject",
"z": "f6f2187d.f17ca8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "prova",
"payloadType": "msg",
"x": 320,
"y": 200,
"wires": [
[
"ffac1725.c59cd8"
]
]
},
{
"id": "ffac1725.c59cd8",
"type": "function",
"z": "f6f2187d.f17ca8",
"name": "",
"func": "var out;\nvar lambda = new AWS.Lambda({\n apiVersion: '2015-03-31',\n endpoint: 'http://172.18.0.4:4566',\n sslEnabled: false,\n region: 'us-east-2',\n accessKeyId: 'test',\n secretAccessKey: 'test'\n});\n\nvar params = {\n FunctionName: 'FindTarga', /* required */\n};\n\nlambda.invoke(params, function(err, data) {\n if (err) {\n console.log(err, err.stack); \n msg.payload=err;\n \n } // an error occurred\n else {\n out = data.Payload.toString(\"utf-8\");\n //console.log(out);\n msg.payload = out;\n console.log(msg.payload);\n }// successful response\n});\nreturn msg;",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [
{
"var": "AWS",
"module": "aws-sdk"
}
],
"x": 540,
"y": 200,
"wires": [
[
"e72d8d71.b49a8"
],
[]
]
}
]