Sid
28 Marzo, 2024 14:35
1
I have a code node in which I have a array I want to access the array in http node.
How can I do this without changing the array data it should be same as output in the code.
Here is the array in code node i want this array to access in the http node.
array name=modiefiedResults:
[
{
“name”: “product”,
“isDiscount”: “false”,
“numberOfItems”: “1”,
“measuringUnitName”: “dollar”,
“currency”: “dollar”,
“code”: “202”,
“quantity”: 1,
“taxPercentage”: 0.19,
“price”: 84.02,
“discountValue”: -8.4034,
“isTaxIncluded”: “”
},
{
“name”: “product1”,
“isDiscount”: “false”,
“numberOfItems”: “1”,
“measuringUnitName”: “dollar”,
“currency”: “dollar”,
“code”: “112”,
“quantity”: 1,
“taxPercentage”: null,
“price”: 100.83,
“discountValue”: null,
“isTaxIncluded”: “”
}
]
n8n
28 Marzo, 2024 14:35
2
It looks like your topic is missing some important information. Could you provide the following if applicable.
n8n version:
Database (default: SQLite):
n8n EXECUTIONS_PROCESS setting (default: own, main):
Running n8n via (Docker, npm, n8n cloud, desktop app):
Operating system:
@Sid , return your array in the Code as the value of modiefiedResults (which is the name you want for your array):
{
"modiefiedResults": [
{
"name": "product",
"isDiscount": "false",
"numberOfItems": "1",
"measuringUnitName": "dollar",
"currency": "dollar",
"code": "202",
"quantity": 1,
"taxPercentage": 0.19,
"price": 84.02,
"discountValue": -8.4034,
"isTaxIncluded": ""
},
{
"name": "product1",
"isDiscount": "false",
"numberOfItems": "1",
"measuringUnitName": "dollar",
"currency": "dollar",
"code": "112",
"quantity": 1,
"taxPercentage": null,
"price": 100.83,
"discountValue": null,
"isTaxIncluded": ""
}
]
}
Then in HTTP Request node you can reference it as {{ $json.modiefiedResults }}.
If you cannot modify it in the Code node you are talking about (I see no reason why though), you can use yet another Code node between your Code node and HTTP Request node and return the values like this
return {
"modiefiedResults": $input.all().map(i => i.json)
};
@Sid ,@ihortom method is correct with code node or else you can use set node and set the output data type to array if that helps
Sid
29 Marzo, 2024 03:50
5
Thank You so much @ihortom You solved my problem.
Thanks for giving your time