Help

Upcoming database upgrades. to improve our reliability at 03:30 UTC on Feb. 25 / 7:30pm PT on Feb. 24. Some users may briefly experience slow load times or error messages. Learn more here

Array with strings via API

Topic Labels: API
713 2
cancel
Showing results for 
Search instead for 
Did you mean: 

Hey! First time here.

Guys, I need the Airtable API to return an array on this format:
image

But the only way I could make it return was in 2 separated arrays, like this:
image

Is there anyway to return it like the first image?

Thanks in advance!

2 Replies 2

Hi,

you will run into trouble if you try to get these values from two separate fields, as the order will be messed up, if either “slug” or “name” is empty.

One way to go about this is to create a function field in your Categories table and reference that instead.
Screen Shot 2021-10-01 at 16.33.42

Here is the formula:

'[{"category":"' & {Name} & '","slug":"' & {Slug} & '"}]'

In you script you will probably have to use the JSON.parse() method, as it will be interpreted as a string and not an object.

@ROARK THANKYOU! Just got it working.