Problem passing data to API

Hi,

I have two API calls in the workflow. First API return results, consolidating using function node with code like this

payment.json.map(i => ({json:i})).forEach(j => paymentsInfo.push(j));

and for second API passing the function node results as input. When I do node[“Function”].json, I only see one item in the input passed to second API as supposed to all items.

Input to the second API body expression is
{{ { “receipts”: $node[“Function”].json } }}

What am I doing wrong here…Please help

@jan an @Jon @RicardoE105

Morning @dsuresh,

Is your first node returning more than one result and on your second node at the top does it have a number?

Which nodes are you using and are you able to send some screenshots of the output of the function and the output of the second node? A full snip of the node pop up box is best and you can edit out anything personal / sensitive.


@Jon

Sent images

second image is the input to the API call

Does that second node have a little number at the top of it? It looks like it should be working but I may be missing something.

@Jon

Hey @dsuresh,

Looking at the screenshot of the Function node, it seems like it is returning 3205 items. If you want to use all the items in a single request, you will have to change the data structure. You can use the Item Lists node for that.
Currently, your data structure is as follow

[
 {},
 {},
...
]

You need to transform it to

[
 [
  {},
  {},
 ...
 ]
]
1 Like

@harshil1712

Can you pls provide more details…sorry

Here’s a small example workflow

The first node returns 5 items. We use the Function node to combine all the items and return all the values in a single item. If you execute both the nodes, you will be able to see the number of items returned by them.
You will have to use a similar function node to combine and return a single item, and pass that to your HTTP Request node.

1 Like

Thanks
@jan
@harshil1712
@Jon
@RicardoE105
Really appreciated.

1 Like

No problem!

Can you please mark the solution that helped you? This will help others find it easily :slight_smile:

Sure, marked as solution

1 Like