I have a workflow that receives data through WebHooks Node, use part of the data to do a lookup on Postgres DB, adds data from the first node to the results from the Postgres DB lookup by using SET node to format it, and then sends that data out with HTTP Node.
It works well but the problem is that, if the database lookup producers 2 or more results only the first results will have data from the First Node (WebHooks Node), other results will be sent out without data from the First Node (WebHooks Node).
Please I need you guys to help me out, How do I fix this?
Can you share your workflow with us? This will help me replicate your issue, and provide you a better solution.
If you’re not sure how to share your workflow, select all the nodes and copy them (use CMD+C or CTRL+C) and paste them here. Please omit any information that you don’t want to share with us.
Can you share the output for the Postgres node and the Set 1 node? I am not able to replicate the issue. I will need more time to set up Postgres, I think.
You can use the Function node to add the data to each entry. The following code snippet might be helpful. Please note, you might have to make a few changes based on your workflow.
var arr = items[0].json;
var new_items=[]
var twilio_number = $node['Set for WebHook'].json["TWILIO_NUMBER"];
var sms = $node['Set for WebHook'].json["SMS"];
for (var i =0; i<arr.length;i++){
new_items.push({"Twilio_Number":twilio_number, "SMS":sms, ...arr[i]})
}
return [{json:new_items}];