Skip to content

Commit

Permalink
fix: use builtin fetch if detected
Browse files Browse the repository at this point in the history
  • Loading branch information
retronav authored and paulrobertlloyd committed Sep 22, 2022
1 parent f6cbefe commit 137cc44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fetch-mf2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fetch } from "undici";
import parser from "microformats-parser";
import { fetch } from "./fetch.js";

/**
* Fetch Microformats2 from a given URL
Expand Down
13 changes: 13 additions & 0 deletions lib/fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Fetch ponyfill.
*
* @type {globalThis.fetch}
*/
export async function fetch(...args) {
if ("fetch" in globalThis) {
return globalThis.fetch(...args);
}

const { fetch } = await import("undici");
return fetch(...args);
}

0 comments on commit 137cc44

Please sign in to comment.