Raw Query Results

Hi All,

I'm connecting to a Rest API to bring data through to my application and after some testing (Aka. Breaking it multiple times until it doesn't break!) .. I have the information I need. My issue is that if I then add this query to a table, it only brings raw data through.

For example, rather than saying:

"Joe Bloggs"
it says
"{"id": 2395, "name": "Joe Bloggs", "team_id: 8 }

I understand it's due to the data but is there a way I can trim these results so it only shows Joe Bloggs, rather than everything before and after please?

On the query itself, I have a 'Transform Results' set to the below (for reference in case it influences anything:)

function transformData(data) {
** const filteredData = data.data.filter(item => item.role && moment(item.enddate).isAfter(moment()) && moment(item.date).isSameOrBefore(moment()));**
** return filteredData;**

return transformData(data);

It looks like unparsed JSON. Retool should be automatically parsing it for you unless the API is returning something that is for some reason unparsable. Maybe it's getting stringified twice or something?

If it's a valid JSON array of objects you can just run the entire array through JSON.parse(data), otherwise if it's some sort of array of separate JSON objects you'll need to do something like data.map(obj=>JSON.parse(obj)).

Hi @JamieB :wave:

Sounds like you may want to transform your results. If you just want an array of names would trying something like const dataNames = filteredData.map( item => item.name) work for you? If not, could you send some screenshots and an explanation of how you're using the data? Thanks! :slight_smile: