Data vs rawData in API response

Hello! I am trying to receive data in my Retool app. The API I am using has 2 endpoints which correspond to 2 control queries. The POST request returns the expected data in both control queries. However, in one of the control queries, the data is returned in rawData but not in data. The other control query contains data in both data and rawData.

In both cases, the data is formatted as follows: [{'key1' : 'value1'}, {'key2' : 'value2}]. Does anyone know why data could be empty in the first control query? More generally, what is the difference between data and rawData in the API response?

Welcome to the forum!
Hard to give a solution without more context.(Screenshots?)
Also, see this: Transform data with JavaScript | Retool Docs

Thanks Scott. More context:
get_commission_payout is the resource query that returns the API response. When I look at get_commission_payout in the State view, the data variable is empty:

However, the rawData variable has the expected data:

Why is the API response being sent to rawData but not to data? The reason I ask is because the transformer uses data, and I can't seem to get the transformer to use rawData instead.

What does the transformer look like?

Here is the transformer I am trying to use:

I used the default transformer (I clicked Enable next to Transformer) and then changed data to rawData.

Any ideas on how to transform rawData to where I can use it in a table would be greatly appreciated.

In the Data source field for a table component you should be able to use:
[{{}}] without using a transformer.
Not clear on why data is NOT populated...

1 Like

Agreed. I am using {{}} from my other resource query and it works like a charm. Now I'm just trying to get the response from get_commission_payout sent to data.

1 Like

Hi @evanlewis,

Thanks for reaching out! I think I might know why this is happening :thinking: If you disable (remove) the transformer, does the query's data property get populated with the expected response?

I have seen a case where the .data is empty, but .rawData has an array of values if the query runs successfully, but the transformer "fails." I have filed a bug for this-- we should be surfacing some error or warning when this happens :disappointed:

For your transformer, you won't want to run formatDataAsArray(data) since the data is already in the proper format.

Let me know if that helps :crossed_fingers:

Thanks Tess! I actually just rebuilt the Retool query and the .data field started populating again. I appreciate your help and hopefully the bug gets resolved soon!

1 Like

Glad to hear you weren't blocked! Thanks for letting us know :slightly_smiling_face:

1 Like