Trouble splitting array items from http request

Hi,

I do an http request and as a result I get a json with an array with some websites.

like this here:

{
“similar_sites”: [
{
“site”: “furniturepipeline.com”,
“rank”: 25252
},
{
“site”: “veeqo.com”,
“rank”: 1449
},
{
“site”: “shopify.com”,
“rank”: 9
},
{
“site”: “skulabs.com”,
“rank”: 2548
},
{
“site”: “365dropship.com”,
“rank”: 10542
},
{
“site”: “modmade.com”,
“rank”: 26113
},
{
“site”: “wholesaledeals.co.uk”,
“rank”: 970
},
{
“site”: “unleashedsoftware.com”,
“rank”: 325
},
{
“site”: “linnworks.com”,
“rank”: 2228
},
{
“site”: “dropshipzone.com.au”,
“rank”: 2272
}
],
“similar_sites_by_rank”: null
}

I get 10 results à 10 “similar_sites” back (as an example)

Then I use a Function with .map to get only the “site”.

for (item of items) {

}

I do 8 HTTP requests and get 8 items back.

The function also returns 8 request wit 8 arrays à 10 items.

But what I need is a result of 80 items, not 8 times 10 items.

How can I consolidate the “site” result , so that I get 80 results back from the function ?

Thanks

Hi there, when you share code here, please put the code in the </> above the text editor so we can see it correctly.

I’m also having a hard time understanding your logic. To pull the array out as different items you will need to use the Item List node and use the Split Out Items operation. For the Field to Split Out just put similar_sites.

Here is an example of what I mean, I am not sure if this is what you mean however. Copy and paste this into your n8n Canvas:

Thanks @djangelic . I trried to split “similiar sites”, but I get “ERROR: Couldn’t find the field ‘similar_sites’ in the input data”

The path to the item is:
$item(“0”).$node[“HTTP Request1”].json[“tasks”][“0”][“result”][“0”][“sites”][“similar_sites”]

I paste below the HTTP response.

I do multiple HTTP requests and get this response back multiple times.

I want to consolidate the “site” below “similiar_sites” to process with them.

Example: 6 HTTP requests à 10 “site”'s = 60 sites as items to proceed with

Thanks for your help, much appreciated

I created a demo node with the result of 2 demo HTTP requests here:

@djangelic would highly appreciate your response :slight_smile:

Hi @passana ,

Sorry been a long week!

Looks like since the result is nested, we can’t seem to use dot notation to extract, so instead we can use multiple item lists. Let me know if this is what you are looking for:

it works @djangelic … Thank you so much for your help ! Much appreciated

1 Like