How to concatenate multiple variables, not just two

Options

Hi,

so my external API function has an input of up to 4 variables that I need to combine into a single param for my API call.

I've been looking around, found "concat" but it seems designed to concatenate only two values.

Here's the specific issue, see the following API call:

https://api.twitter.com/2/tweets/search/recent?query=indie lang:es place_country=ES -is:retweet&tweet.fields=public_metrics,text,author_id,entities,context_annotations&expansions=author_id&place.fields=id,full_name,country,country_code,place_type&user.fields=id

Param query is constructed with multiple inputs, topic, lang, place_country… separated by a whitespace

I have a variable query where I need to concatenate those inputs separated by a whitespace to pass into the API call.

I guess I could go by steps:

concatenate topic+lang, then concatenate topiclang+place… and so on.

Is it there a better way to do this?

Best Answer

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Answer ✓
    Options

    Hey @Carlos chaining your concat filters is a great way to do this! I see nothing wrong with this approach. Another filter you could consider for this is sprintf, it might look a little cleaner to the eye. You might consider building the parameter in a variable first too so your external API request function doesn't use as much vertical real-estate.

Answers