• Instructions to Ask a Question

    For any assistance, please click the "Ask a Question" button and select the Pabbly product for which you require support.

    We offer seven comprehensive applications designed to help you efficiently manage and grow your business:

    Our support team endeavors to respond within 24 business hours (Monday to Friday, 10:00 AM to 6:00 PM IST). We appreciate your understanding and patience.

    🚀 Exclusive Lifetime Offers 🚀

    We invite you to take advantage of our special one-time payment plans, providing lifetime access to select applications:

    • 🔥 Pabbly Connect — Lifetime Access for $249View Offer
    • 🔥 Pabbly Subscription Billing — Lifetime Access for $249View Offer
    • 🔥 Pabbly Chatflow — Lifetime Access for $249View Offer

    Make a one-time investment and enjoy the advantages of robust business management tools for years to come.

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

Moderator
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