Closed dnm13 closed 2 years ago
Code example / usage
search(site, `id:${post_id}`)
.then(r => {
var data: BooruPost = r.posts[0] as any;
data.thumbnail = getThumbnail(r.posts[0] as any)
data.site_name = r.posts[0].booru.domain
data.extension = data.fileUrl.split('.').pop() || 'jpg'
data = AutoTag('booru', data as any)
res(data)
})
.catch(err => {
console.log(err);
res(false)
})
Looks like you're using electron, right?
It doesn't seem like electron supports fetch
natively so window.fetch
is undefined while window
is defined
If undici works on electron I can add in an extra check, but if it doesn't you'll have to polyfill window.fetch
with a working electron fetch
Looks like you're using electron, right?
It doesn't seem like electron supports
fetch
natively sowindow.fetch
is undefined whilewindow
is definedIf undici works on electron I can add in an extra check, but if it doesn't you'll have to polyfill
window.fetch
with a working electronfetch
Yes. I'm using electron. But it's really weird since it has worked for long on my app (electron). I'm not sure what triggered this but it's only recently that this error is thrown.
The actual line defining resolvedFetch
hasn't changed since 2.3.0
const resolvedFetch = typeof window !== 'undefined' ? window.fetch.bind(window) : fetch
2.5.7 did change from using node-fetch
to undici
for the actual fetch
, which might be why?
Are you trying to run booru
from the main process or the renderer process? Which version of electron?
I tried Electron 19.0.6 and it works on both the main process and renderer process (with a brute-force nodeIntegration: true
but still)
It's Electron v15.1.0 No, I run Booru from main process
MB for the late response
I can reproduce it on Electron v15.1.0, but not on v16.0.0
The issue is the Node.js version
Node.js 16.5.0, Chromium 94.0.4606.61, and Electron 15.1.0.
Node.js 16.9.1, Chromium 96.0.4664.45, and Electron 16.0.0.
Undici only supports fetch
on Node.js v16.8+, so undici.fetch
doesn't exist on Electron v15
Since Electron v15 is no longer supported I'd recommend updating Electron first. Ideally to a currently-supported version, but even just to v16 would work
If you absolutely can't update Electron I could look into a way of passing your own fetch
, but I suggest updating Electron before you run into more issues like these
That worked Thank you
Booru version: 2.6.2 Node version: 14.15.0
Tried with any booru. Before that, using v2.4.0, every NSFW boorus throws an error like this:
While SFW boorus works normally.