Code Node array to http node

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”: “”

}

]

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)
};
1 Like

@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

Thank You so much @ihortom You solved my problem.
Thanks for giving your time

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.