How do I show the .data._ output of two or more REST queries using expressions in a Table's "Data" field

Hi .. I am a new user to this great tool. I am trying to show the (.data._) output of two or more REST queries using expressions in a Table's "Data" field. I am trying to show the result of the query that finishes 1st followed by the 2nd & 3rd, etc. The output fields of all the queries are an exact match with a difference in the captured values. Using the "&&" only shows the output of the 2nd query (see attached screen capture).
Thks & Rgds
Mohd

1 Like

Hi @majeed9001! In Javascript (which is what Retool accepts in between double curly brackets), the && operator actually evaluates truthiness, rather than combine multiple objects together (which is sounds like you're trying to do with your query).

Here's a quick example of how && might work:

https://docs.retool.com/docs/javascript-in-retool#operators

For your use case, you might want to use something more like Object.assign, which essentially smooshes two objects together.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

As a note, Object.assign will include all columns whether or not your queries have the same columns or different columns (e.g. query5 has id, name and query6 has object_id, price). Let me know how this works for you!

Hi victoria and thank you for your prompt reply. The Object.assign
returns the 2nd query value only (see attached). What am I doing wrong?

Here is another screen shot showing


the content of the data.

Ah! So you have the same columns/keys in both objects, you just want to combine the values?

If so, then something like this should work for you:

{{formatDataAsArray(query1.data).concat(formatDataAsArray(query2.data))}}

This converts each query.data object into an object of arrays and them combines them all! Let me know how this goes for you :crossed_fingers:

Thank you victoria. The following worked for me:
{{Grp1_Results.value.concat(Grp2_Results.value)}}

Kind Regards,
Mohd

Excellent! Glad to hear it worked for you :star_struck: Let us know if you have any other questions!