Is there a way to download fetch library for javascript? I am working on Lyniate Rhapsody application. It has a javascript filter in which I would like to call an API and transform the output from JSON to XML.
I am using the below snippet of code but it is giving an error
Code:
const options = {
method: 'GET',
headers: {
'X-RapidAPI-Key': '123',
'X-RapidAPI-Host': 'weatherapi-com.p.rapidapi.com'
}
};
fetch('https://weatherapi-com.p.rapidapi.com/future.json?q=London&dt=2022-12-25', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
Error message:
com.orchestral.rhapsody.module.api_2_0.impl.adapter.in.FilterConfigurationExceptionAdapter: Error configuring filter: Exception compiling script: The following errors were detected in the JavaScript.
ERROR:JavaScript:13:19:syntax error
.then(response => response.json())
ERROR:JavaScript:14:19:syntax error
.then(response => console.log(response))
ERROR:JavaScript:15:8:syntax error
.catch(err => console.error(err));
ERROR:JavaScript:1:0:Compilation produced 3 syntax errors.
at com.orchestral.rhapsody.module.api_2_0.impl.adapter.in.FilterAdapter.configure(FilterAdapter.java:13)
at com.orchestral.rhapsody.component.type.spi.FilterProxyImpl.configure(FilterProxyImpl.java:19)
at com.orchestral.rhapsody.testing.filter.spi.filter.FilterTestingContext$1.doCall(FilterTestingContext.java:9)
at com.orchestral.rhapsody.testing.filter.spi.filter.FilterTestingContext$1.doCall(FilterTestingContext.java:3)
at com.orchestral.rhapsody.testing.filter.spi.filter.ComponentTestingContext$ComponentTestingCallable.call(ComponentTestingContext.java:8)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at com.orchestral.rhapsody.testing.filter.spi.filter.ComponentTestingExecutorService$1$1.run(ComponentTestingExecutorService.java:3)
Caused by: com.orchestral.rhapsody.module.api_2_0.module.filter.FilterConfigurationException: Error configuring filter: Exception compiling script: The following errors were detected in the JavaScript.
ERROR:JavaScript:13:19:syntax error
.then(response => response.json())
ERROR:JavaScript:14:19:syntax error
.then(response => console.log(response))
ERROR:JavaScript:15:8:syntax error
.catch(err => console.error(err));
ERROR:JavaScript:1:0:Compilation produced 3 syntax errors.
at com.orchestral.rhapsody.modules.standard.filters.executescript.ExecuteScript.doConfigure(ExecuteScript.java:40)
at com.orchestral.rhapsody.module.api_2_0.module.filter.AbstractFilter.configure(AbstractFilter.java:11)
at com.orchestral.rhapsody.module.api_2_0.impl.adapter.in.FilterAdapter.configure(FilterAdapter.java:28)
at com.orchestral.rhapsody.component.type.spi.FilterProxyImpl.configure(FilterProxyImpl.java:19)
at com.orchestral.rhapsody.testing.filter.spi.filter.FilterTestingContext$1.doCall(FilterTestingContext.java:9)
at com.orchestral.rhapsody.testing.filter.spi.filter.FilterTestingContext$1.doCall(FilterTestingContext.java:3)
at com.orchestral.rhapsody.testing.filter.spi.filter.ComponentTestingContext$ComponentTestingCallable.call(ComponentTestingContext.java:8)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at com.orchestral.rhapsody.testing.filter.spi.filter.ComponentTestingExecutorService$1$1.run(ComponentTestingExecutorService.java:3)
Caused by: com.orchestral.rhapsody.javascript.ScriptException: Exception compiling script: The following errors were detected in the JavaScript.
ERROR:JavaScript:13:19:syntax error
.then(response => response.json())
ERROR:JavaScript:14:19:syntax error
.then(response => console.log(response))
ERROR:JavaScript:15:8:syntax error
.catch(err => console.error(err));
ERROR:JavaScript:1:0:Compilation produced 3 syntax errors.
at com.orchestral.rhapsody.javascript.spi.JavaScriptServiceImpl.compileJavaScriptCode(JavaScriptServiceImpl.java:25)
at com.orchestral.rhapsody.modules.standard.filters.executescript.ExecuteScript.doConfigure(ExecuteScript.java:31)
at com.orchestral.rhapsody.module.api_2_0.module.filter.AbstractFilter.configure(AbstractFilter.java:11)
at com.orchestral.rhapsody.module.api_2_0.impl.adapter.in.FilterAdapter.configure(FilterAdapter.java:28)
at com.orchestral.rhapsody.component.type.spi.FilterProxyImpl.configure(FilterProxyImpl.java:19)
at com.orchestral.rhapsody.testing.filter.spi.filter.FilterTestingContext$1.doCall(FilterTestingContext.java:9)
at com.orchestral.rhapsody.testing.filter.spi.filter.FilterTestingContext$1.doCall(FilterTestingContext.java:3)
at com.orchestral.rhapsody.testing.filter.spi.filter.ComponentTestingContext$ComponentTestingCallable.call(ComponentTestingContext.java:8)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at com.orchestral.rhapsody.testing.filter.spi.filter.ComponentTestingExecutorService$1$1.run(ComponentTestingExecutorService.java:3)
Caused by: com.orchestral.rhapsody.javascript.compiler.JavaScriptCompilationException: The following errors were detected in the JavaScript.
ERROR:JavaScript:13:19:syntax error
.then(response => response.json())
ERROR:JavaScript:14:19:syntax error
.then(response => console.log(response))
ERROR:JavaScript:15:8:syntax error
.catch(err => console.error(err));
ERROR:JavaScript:1:0:Compilation produced 3 syntax errors.
at com.orchestral.rhapsody.javascript.compiler.spi.JavaScriptCompilerImpl.compileJavaScriptCode(JavaScriptCompilerImpl.java:29)
at com.orchestral.rhapsody.javascript.compiler.spi.JavaScriptCompilerServiceImpl.compileJavaScriptCode(JavaScriptCompilerServiceImpl.java:6)
at com.orchestral.rhapsody.javascript.spi.JavaScriptServiceImpl.compileJavaScriptCode(JavaScriptServiceImpl.java:42)
at com.orchestral.rhapsody.modules.standard.filters.executescript.ExecuteScript.doConfigure(ExecuteScript.java:31)
at com.orchestral.rhapsody.module.api_2_0.module.filter.AbstractFilter.configure(AbstractFilter.java:11)
at com.orchestral.rhapsody.module.api_2_0.impl.adapter.in.FilterAdapter.configure(FilterAdapter.java:28)
at com.orchestral.rhapsody.component.type.spi.FilterProxyImpl.configure(FilterProxyImpl.java:19)
at com.orchestral.rhapsody.testing.filter.spi.filter.FilterTestingContext$1.doCall(FilterTestingContext.java:9)
at com.orchestral.rhapsody.testing.filter.spi.filter.FilterTestingContext$1.doCall(FilterTestingContext.java:3)
at com.orchestral.rhapsody.testing.filter.spi.filter.ComponentTestingContext$ComponentTestingCallable.call(ComponentTestingContext.java:8)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at com.orchestral.rhapsody.testing.filter.spi.filter.ComponentTestingExecutorService$1$1.run(ComponentTestingExecutorService.java:3)
Any idea what needs to be done?