Grab entire object response within Code <> JavaScript

matg

Member
Hi,

I have an API response that has 1 to many responses, and instead of nesting it in an array it returns as many keys as there are items and increments the index... mediaUrl0, mediaUrl1, etc. it can be as many as mediaUrl20... here's an example:


1746802203947.png


My goal is to store all of these media strings in an array field in a postgres database, and I was going to write a simple Pabbly Code <> JavaScript workflow that will loop over the objects and pluck any that match a regex similar to mediaUrll\d+ and then create the literal insert statement, e.g. ["https://url1", "https://url2"] and insert that way


Hover, when using code I can only grab individual keys off of the response object, I cannot figure out how grab the entire response as an object so that I could grab the keys and do the aforementioned work, e.g.

1746802424357.png



is it possible to get the entire raw response as an object here?

Thanks,
MatG
 

ArshilAhmad

Well-known member
Staff member
Hi @matg,

Please disable 'Simple Response', then click the 'Save & Send Test Request' button and check if the response is returned in the form of an array
1746810931213.png
 
Top