0
FilePond.setOptions({        
    server: {            
        fetch: (url, load, error, progress, abort, headers) => {            
            fetch(url)
                .then(res => res.blob())
                .then(load);
        }

I've found this configuration online. I cannot understand why this works. Should'nt this lead to a stack-overflow?

IMO the function is calling itself recursively or am i getting anything wrong?

Felix D.
  • 4,811
  • 8
  • 38
  • 72

1 Answers1

1

In this example the first fetch is a property of server, the second fetch is the JavaScript native fetch function.

You could also write it like this, which maybe makes things a bit more clear?

function getData(url, load) {
  return fetch(url)
    .then(res => res.blob())
    .then(load)
}

const options = {
  server: {
    fetch: getData
  }
}

FilePond.setOptions(options);
Rik
  • 3,328
  • 1
  • 20
  • 23