0

I have a use case of performing an API call, which accepts parameters like this:

api('str1', 'str2', 'str3');

I don't want to hardcode all parameters so I'm trying to do something like this:

const LIST: string[] = ['list-item-1', 'list-item-2'];

api('str1-hardcoded', LIST.join(','))

But this does not solve the issue, as join produces a single string from all items which is not what I want.

What would be the best way to handle this?

0

1 Answer 1

1

You just need use ...

const LIST: string[] = ['list-item-1', 'list-item-2'];

api('str1-hardcoded', ...LIST)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.