Incorrect syntax for data.map

Hi,

I'm trying to display all records from a query (well, just on column called "company_name") into a text box.

I think I am missing something simple from my code - but all I am getting as a result is the commas between the records - not the string of 'company_name I expect (Although it knows the record count - as it places the correct number of commas.....

{{get_company_data_by_sector.data.sector_name.map((record) => record.value).join(',')}}

image

Can anyone guide me to the correct syntax?

thanks
Neil

.data.sector_name returns an array of values

So to display a string of all values, you could do something like:

.data.sector_name.join(‘ ‘)

https://sourcefreeze.com/how-to-convert-array-to-space-separated-strings-in-javascript/

Would that work for you? :slightly_smiling_face:

1 Like

Thanks Victoria, that will teach me to use ChatGPT (although it has been a great help tbh - as, I am no coder!).

It seems my code was overly complicated. Your code has tidied things up and got it working. Thanks!

new_code

1 Like