Newibie Help

Hi

I am struggling for weeks, going through the forum to try find similar answer that can help me solve this issue.

At the last step in this workflow I am left with the output which I would like to be able to do a few things.

  1. To start with to be able to split the three “teams” into seperate Items so that i can inser each item into a new node placeholder.
  2. To be able to read as many lines and split those lines into seperate items. The reason for this is sometimes I might receive 3 teams as in the example, however other times maybe 13.

Thanks in advance for the help!

Please share the workflow

Share the output returned by the last node

`
[

{

“0”:“Denver Broncos”,

“1”:“Los Angeles Chargers”,

“2”:“Kansas City Chiefs”

}

]`

Information on your n8n setup

  • n8n version: 0.207.0
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: docker

Hey @Surge.Media,

to be honest I’m not 100% sure what you’re trying to achieve. Maybe you can help me to describe a little more what you’re trying to do?

But before we start, I see that you’re mocking your data in the first function node. It seems to have a very weird data structure though. Your teams inside the leagues for example are currently not using an array format

//this is your format right now:
"nfl": {0:"Denver Broncos", 1: "Los Angeles Chargers"}
// this is a format I would expect
"nfl": ["Denver Broncos", "Los Angeles Chargers"]

but some other weird format that looks like an array. Are you sure that this is the correct data format you would expect when receiving the real data?

1 Like

Hi @Niklas_Hatje thanks for the pointer, this is the structure I am getting from the provider, however I will ask them to restructure it.

Basically what I am trying to do is (taking into account we get the data in the format you suggested), then be able to take the teams for NFL and insert them into a users contact card inside Mautic (basically can think of it as taking the three teams and putting them into a single cell in a google sheet).

This is the data i receive in my webhook:


[
{
"headers":
{
"host":
"n8.surge.media",
"content-length":
"208",
"accept":
"*/*",
"content-type":
"application/json",
"x-forwarded-for":
"99.199.999.9",
"x-forwarded-host":
"n8n-testinstnace",
"x-forwarded-port":
"443",
"x-forwarded-proto":
"https",
"x-forwarded-server":
"7c1552b2eb62",
"x-real-ip":
"99.199.999.9",
"accept-encoding":
"gzip"
},
"params":
{
},
"query":
{
},
"body":
[
"[email protected]",
"4123971566",
"Alabama",
{
"nfl":
"nfl",
"nba":
"nba"
},
{
"nfl":
[
"Denver Broncos",
"Los Angeles Chargers",
"Kansas City Chiefs"
],
"nba":
[
"Boston Celtics",
"Brooklyn Nets",
"New York Knicks"
]
}
]
}
]

I finally got this solved with the assistance of someone else, here is the solution that worked for me

let teams_list = ""
for (let i of item.json.body[4].nfl){
  teams_list = teams_list + i + ", "
}


return {json:{'teams':teams_list.slice(0, -2)}}
// return {'ouput':Object.values(item.json.body[4])}

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