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?
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);