Separate array into string json api

Try to pass urls to api. Need to break out variable which is a array.

{
"urls": [
{{createTemplatePDF.data.download_url}},{{multiselectListboxProposalBuilderAttachDocuments.value}}
]

Need the multiselectListBoxProposalBuilderAttachDocuments.value data to be converted to separate urls not in an array.

@nroeder perhaps grouping the curly braces would make this easier?

Is this what you are trying for?

{
"urls": {{ [
createTemplatePDF.data.download_url,
... multiselectListBoxProposalBuilderAttachDocuments.value
] }}
}

1 Like

{
"urls": {{ [
createTemplatePDF.data.download_url,
multiselectListboxProposalBuilderAttachDocuments2.value
] }} ,
"export_type": "json",
"expiration": 5
}

results in
{
"status": "error",
"message": "TypeError: url.startsWith is not a function"
}

@nroeder The code you sent back does not have the spread operator ...multiselectListBoxProposalBuilderAttachDocuments.value

Thanks! sorry I didn't realize ... actually meant something.

Yes, this example is taking an array of URLs like urlArray = ["a","b"] and joining it as part of another array with one URL like url1 = "c" Thus, the resultant array URLs = [url1, urlArray] yields ["c", ["a","b"]] an array whose first element is url1 and whose second element is urlArray, an array of URLs. The spread operator (triple dots) will return the elements from an array thus [url1, ...urlArray] yields ["c", "a", "b"] an array whose first element is url1 and whose other elements are those elements from urlArray. I hope this helps!