Loop / For Each / Other

https://api.twitter.com/2/lists/{{$node[“GetTwitterLists”].json[“data”][0][“id”]}}/members

Instead of item [0] in array above, I want to loop through all

How to do this please?

In other words, do you have the concept of wildcard, eg: * instead of the [0] ?

Hey @Arno_Nel,

Welcome to the community :tada:

Depending on the node you are using and the data format it may just loop itself internally. Do you have an example workflow you can share that shows what you are doing?

Not sure if I am articulating myself, but let me give another go

https://api.twitter.com/2/lists/{{$node[“GetTwitterLists”].json[“data”][0][“id”]}}/members

That http request works, as it returns an ID, eg: 123456456

https://api.twitter.com/2/lists/{{$node[“GetTwitterLists”].json[“data”][1][“id”]}}/members

That http request works, as it returns another ID, eg: 987654654

So question is what, do I put instead of this:

https://api.twitter.com/2/lists/{{$node[“GetTwitterLists”].json[“data”][0][“id”]}}/members

so that it loops through all. In laymans, could I put a wildcard to signify all, eg:

https://api.twitter.com/2/lists/{{$node[“GetTwitterLists”].json[“data”]*[“id”]}}/members

Dont just want first item, want all

Am i making sense?

Hey @Arno_Nel,

You are making sense but most nodes will do the looping for you, There is no * option so it would be very handy if we can get an example workflow that shows the input data structure so we can get an example together for you.

It could be that if you pop an item list node before the node you are using and use data as the split field you migt be able to use $json[“id”]

Does above help?

Hey @Arno_Nel,

It does indeed, So the data coming back from twitter is an array contained in one field. Using the Items List node that can be split into individual items that you can then process in the last node using {{$json["id"]}}

The example workflow below shows this in action, I gave it a run and I get an unauthorized error from Twitter on the last step but I assume your account will be fine for it.

Example Workflow
1 Like

Awesome, thank you ! :slight_smile:

1 Like