Help

Re: Array with strings via API

2464 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Locare_Cosmetic
4 - Data Explorer
4 - Data Explorer

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
ROARK
6 - Interface Innovator
6 - Interface Innovator

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.

Locare_Cosmetic
4 - Data Explorer
4 - Data Explorer

@ROARK THANKYOU! Just got it working.