node-fetch patch by jimmywarting #181

Merged
Sirherobrine23 merged 2 commits from node_fetch-3.0 into main 2021-09-06 17:37:57 +00:00
Showing only changes of commit 5a1d812b85 - Show all commits

View File

@@ -1,7 +1,7 @@
const fetch = (...args) => import('node-fetch').then(mod => mod.default(...args));
if (typeof fetch === "undefined") global.fetch = fetch;
const fetchS = (...args) => import("node-fetch").then(mod => mod.default(...args));
if (typeof fetch === "undefined") global.fetch = fetchS;
module.exports = {
JSON: async (url = "", options) => await (await fetch(url, options)).json(),
TEXT: async (url = "", options) => await (await fetch(url, options)).text(),
BUFFER: async (url = "", options) => Buffer.from(await (await fetch(url, options)).arrayBuffer()),
JSON: async (url = "", options) => await (await fetchS(url, options)).json(),
TEXT: async (url = "", options) => await (await fetchS(url, options)).text(),
BUFFER: async (url = "", options) => Buffer.from(await (await fetchS(url, options)).arrayBuffer()),
}