Share feedback, ideas and get community help

Updated 5 months ago

Ho to get a value from webhook based on other value.

At a glance

The community member has a webhook that returns data, and they want to extract the DOCUMENT_ID and DOCUMENTNAME after collecting the COMPANY_ID. They are using a code snippet to filter the data, but they are not getting the expected results.

Another community member suggests that the filtering should be done on the backend instead of the frontend, as it would be more efficient. The original poster confirms that they could do the filtering on the backend if possible.

Hi, I have a webhook returning something as:
I´d like to get the DOCUMENT_ID and DOCUMENTNAME after I collect the COMPANY_ID

I am using the next code to get the and save in a variable, but I get no look:

data.Database.filter((el) => el.COMPANY_ID == {{ r_menu_sel_clube }}).flatMap((item) => item.COMPANYDOCS.flatMap((doc) => doc.DOCUMENT_ID + "-" + doc.DOCUMENTNAME))

{ "Database": [ { "ASSOCIADO_ID": 2494, "COMPANY_ID": 5, "COMPANYDOCS": [ { "LINE": 1, "DOCUMENT_ID": 43, "DOCUMENTNAME": "Declaração LALAL" }, { "LINE": 2, "DOCUMENT_ID": 11, "DOCUMENTNAME": "Declaração PAPAP" }, ] }, { "ASSOCIADO_ID": 14297, "COMPANY_ID": 6, "COMPANYDOCS": [ { "LINE": 1, "DOCUMENT_ID": 43, "DOCUMENTNAME": "Declaração AA" }, { "LINE": 2, "DOCUMENT_ID": 11, "DOCUMENTNAME": "Declaração CC" }, ] }, ] }
B
L
3 comments
why are you using filter here? Can't you trigger the filter directly with your request parameters?
@Baptiste Do you mean I´d make the filtering on backend?
Yes, that's definitely how it should be done! If possible?
Add a reply
Sign up and join the conversation on Discord