I’m working on an n8n workflow and I’m running into a problem. When I use certain nodes, like the HTTP node, I’m losing some important input data. The biggest issue is that I’m losing the input ID, which I need later for merging.
Does anyone know how to keep the input data in the output so I can use it for merging later?
Here’s what I’m trying to do:
I have an HTTP node set up to fetch some content. In the node settings, I’m using this JSON:
{
"formats": ["markdown"],
"onlyMainContent": true,
"waitFor": 0,
"mobile": false,
"skipTlsVerification": false,
"timeout": 30000,
"location": {
"country": "US"
},
"blockAds": true,
"url": "{{ $json.company_url }}",
"actions": []
}
The thing is, I want to keep the input customer_id
(for example) along with this data. How can I make sure this information isn’t lost when the node runs? Any tips on preserving data across nodes in n8n would be super helpful. Thanks!
yo John_Fast, i’ve had that issue too. one thing that works for me is using the ‘Function’ node after the HTTP Request. you can do something like this:
return items.map(item => ({
json: {
...item.json,
http_response: item.json
}
}));
this keeps your original data and adds the http response. hope it helps!
Have you considered using the Set node in your workflow? It’s a handy tool for preserving data across nodes. You can place a Set node right after your HTTP Request node and use it to combine the incoming data with the HTTP response. Here’s a quick example of how you might set it up:
{
"customer_id": "={{$json['customer_id']}}",
"http_response": "={{$json}}"
}
This way, you’re creating a new object that contains both the original customer_id and the full HTTP response. You can then use this combined data in subsequent nodes without losing any information. Just make sure to reference the correct keys when you need to access specific pieces of data later in your workflow.
Remember to test your workflow thoroughly after making changes. Sometimes, unexpected issues can crop up when modifying data flow between nodes.
Hey there, John_Fast! I’ve run into similar issues with n8n workflows before. One trick I’ve found really useful is using the ‘Function’ node right after your HTTP Request node. It’s a bit more flexible than the Set node and lets you manipulate the data however you need.
Here’s a quick example of what you could do in a Function node:
const newItem = {
customer_id: $input.all()[0].json.customer_id,
http_response: $input.all()[0].json
};
return [{ json: newItem }];
This combines your original customer_id with the full HTTP response. You can adjust this to include any other input fields you need to keep.
Another tip: if you’re dealing with multiple items, you might want to use a loop in your Function node to process each item individually. This ensures you’re not losing any data when dealing with bulk operations.
Hope this helps! Let me know if you need any clarification on setting this up in your workflow.