Server Connect: Looping over the array received to form the input for another server connect

Hi,

I have two server connects. The first one returns an array of objects as per wappler’s design. In that object is contained an id field.

My next server connect accepts an array of ids to return data. The question is how do I convert the array of objects in to the array of ids that I can pass on to my server connect #2. Have tried multiple things like data iterator, array source…but haven’t able to work this out :frowning:

Hi… I’ve been stuck on this for a while now. Can someone please help me out?? Please let me know if the question is not clear I can share screenshots etc.

@Teodor @nshkrsh

Can you please explain what are you trying to achieve? And how do you need to pass the data? Are you sure you need two server actions, or are you just trying to filter one query with the results of another?

question unclear to me.
but try this in console to see if it gives you the output you want:
dmx.parse(“sc1.data.queryArr1.values(yourIDField)”)

Thanks @Teodor “Or are you just trying to filter one query with the results of another?”

Yes, that’s what I was trying to do. Your question has given me the answer. I hadn’t learned that you could connect multiple queries in one server connect. I was trying to call all the server connects in the app first and trying to link them there.

Thanks! this helps, but I’ve not been able to solve it completely as the output of a query is an array of objects [ {id:1}, {id:2} ]. But the next query accepts an array.

How do I convert [ {id:1}, {id:2} ] into [1,2]? Should I run a forEach function on the original array or is there a UI led way to do it? ( My server model is nodeJS)

yourarray.groupBy(‘id’).keys() should give u what you wanted. Im not in front of my system but have used those two formatters a lot

1 Like

That’s right, using:

{{query1.groupBy('id').keys()}}

will return the ids from the first query like [1,2,3]

1 Like