FilePond.setOptions({
server: {
fetch: (url, load, error, progress, abort, headers) => {
fetch(url)
.then(res => res.blob())
.then(load);
}
我在网上找到了这个配置。我不明白为什么会这样。这不应该导致堆栈溢出吗?
IMO 函数正在递归调用自己还是我有什么问题?
在这个例子中,第一个fetch
是 的属性server
,第二个fetch
是 JavaScript 本机 fetch 函数。
你也可以这样写,这样可能会更清楚一些?
function getData(url, load) {
return fetch(url)
.then(res => res.blob())
.then(load)
}
const options = {
server: {
fetch: getData
}
}
FilePond.setOptions(options);