Workflow Bug - Data Property Added

  1. My goal:
    Modifiying an API Result with a Code Block
  2. Issue:
    It Seems that the Query Block added Data Properties to an Array of Objects:
    the Structure that Comes back from the API is :
    [object, object] .. but when i inspect the result it seems that the workflow has modified it to : [{ data : object}, { data: object}]
  3. Steps I've taken to troubleshoot:
    None so far!
  4. Additional info: (Cloud or Self-hosted, Screenshots)
    Retool Cloud

Please advise ASAP as my workflow is Failing due to that!

Thanks


Hi @Martin_M . If I understand correctly, your data is being nested into an extra data object but you want it to just return a single array of objects so you can access it directly?

Sorry, just trying to make sure I understand the issue correctly

exactly, and it did work before, i haven't changed anything about the code.

also in the screenshots you see, when i go to "data" view the extra object isn't there, but in the json view it is. if i download the json, its also there.

I think the API response structure might have changed. Can you try to add a code step immediately after the query that does this:

return querystep.data.map(item => item.data ? item.data : item)

This checks whether each item is nested under data. If it is, it extracts the inner object; if not, it keeps the item as is. That way, you’ll always get the expected array format, and you can continue using it in your code.

Please let me know if this works for you

Hello,

The API structure has definetly not changed, as i still can request the data for example via Postman, and its not the same structure.

Sure i could add that block, but i assume that i'd have the same issue in many other workflows, as im working with the directus API, and the API always returns the same structure.

Kind regards & Many Thanks for your help tough!

Anyone from the Retool Workflow Team who can help with that?

Thks!

Hey @Martin_M - I'm not sure how this slipped through the cracks, but wanted to circle back and ask whether you still need any assistance!

What kind of resource are you working with? You kind of imply that it's a REST API query, but I'm not sure about that. Regardless, Retool should never modify the structure of the returned data so there is definitely something fishy going on.