Tried to use villus to make a query in a service worker:
villus.esm.js:236 Uncaught Error: Could not resolve a fetch() method, you should provide one.
at fetch (villus.esm.js:236:15)
at defaultPlugins (villus.esm.js:337:49)
at index.ts:22:12
villus.esm.js:
function fetch(opts) {
const fetch = (opts === null || opts === void 0 ? void 0 : opts.fetch) || resolveGlobalFetch();
if (!fetch) {
throw new Error('Could not resolve a fetch() method, you should provide one.');
}
Maybe self should be also checked here for workers:
function resolveGlobalFetch() {
if (typeof window !== 'undefined' && 'fetch' in window && window.fetch) {
return window.fetch.bind(window);
}
if (typeof global !== 'undefined' && 'fetch' in global) {
return global.fetch;
}
return undefined;
}
Tried to use villus to make a query in a service worker:
villus.esm.js:
Maybe
self
should be also checked here for workers: