I am going crazy trying inserting this JavaScript line into the WSO2 ESB script mediator:
response.forecast = response.forecast.map( s => Object.values(s)[0] );
after the insertion of this line into my script, trying to save I obtain an error message into the Developer Studio. It is finding a syntax error related to this line (performing the same JavaScript into my browser it works fine and I have no error. I tried to save it anyway and to deploy as Carbon application but now I obtain error in the Carbon console:
Caused by: javax.script.ScriptException: org.mozilla.javascript.EvaluatorException: syntax error (<Unknown Source>#217)
at com.sun.phobos.script.javascript.RhinoScriptEngine.compile(RhinoScriptEngine.java:341)
at com.sun.phobos.script.javascript.RhinoScriptEngine.compile(RhinoScriptEngine.java:323)
at org.apache.synapse.mediators.bsf.ScriptMediator.initInlineScript(ScriptMediator.java:399)
... 32 more
What could be the problem? Why this line is creating problem only into the WSO2 ESB script mediator?
Maybe have I to escape some character or something like this? How can I try to fix this issue?