Forum Academy Marketplace Showcase Pricing Features

JS Fetch issue, using Toolbox plugin

I’m using the Toolbox plugin to be able to use JS in a workflow. In this particular case I am trying to run the fetch method on an API url, but I get “TypeError: NetworkError when attempting to fetch resource”

The reason I want to use JS/Fetch, is to get 240 values from the API/json and calculate some averages and min/max values, using JS.

I have been informed that the error message might be related to the API not allowing CORS. I was hoping someone could point me in a direction of an alternative, or workaround.

fetch('https://power.larc.nasa.gov/api/temporal/monthly/point?parameters=ALLSKY_SFC_SW_DNI&community=RE&longitude=48.0000&latitude=27.0000&format=JSON&start=2001&end=2020')
  .then(response => {
    // Will do things with the response data here
   }).catch((error) => {
    console.log(error)
   });