I am calling an API from server connect. The API is returning a String that includes several \n\n.
In server connect, I am trimming this string and splitting it into an array as follows:
{
"name": "api_outputtext",
"module": "core",
"action": "setvalue",
"options": {
"value": "{{api1.data.choices[0].text.trim()}}"
},
"meta": [],
"outputType": "text",
"output": true
},
{
"name": "output_array",
"module": "core",
"action": "setvalue",
"options": {
"value": "{{api_outputtext.split(/\n\n/)}}"
},
"meta": [],
"outputType": "array",
"output": true
}
I can see the correct answer in the developer tools of my browser:
["Customer Segments: The customer segments for this startup is small businesses that require their own software data to carry out their activities. They will be primarily located in North America, but this startup is ready to support businesses located worldwide. The customer segment could be businesses of any sizes, ranging from startups to Fortune 500 companies.","Problem: With the constant advancement of technology, small businesses need to find a way to keep up. Many companies do not have the ample resources for R&D and software development to stay competitive and up to speed. Thus, many of them remain stuck with the outdated and often times inefficient systems and softwares that have limited capabilities."]
However, when retrieving this data on the Frontend through a POST form, I get an undefined value:
<form id="form_1" method="post" is="dmx-serverconnect-form" >action="/api/Folder/generateText" dmx->on:success="browser1.alert(form_1.data.output_array[0])">
I tried several combinations without success, is it related to a bug or to a mix between JS functions and DMX functions in my code? Thank you in advance for your guidance