inrupt / universal-fetch

A library to access fetch in any node or browser environment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

⚠️ This package is deprecated now that Node 16 has reached EOL. fetch now exists as a global function Node 18 and higher so the global fetch function should be used instead of this package.

Universal Fetch

@inrupt/universal-fetch is a TypeScript library for accessing the fetch method from any environment.

In browsers, this library will always re-export the existing fetch function from the global scope.

In Node.js environments, the library first checks if fetch is globally available (as is the case in Node 18, and is being back-ported into Node 16), then the global fetch is used. Otherwise, the fetch function exported by undici is used for Node 16, and node-fetch is used for Node 14-and-below.

Usage

import fetch, { Headers, Request, Response } from "@inrupt/universal-fetch";

const response = await fetch(url);

Changelog

See the release notes.

License

MIT © Inrupt

About

A library to access fetch in any node or browser environment

License:MIT License


Languages

Language:TypeScript 79.4%Language:JavaScript 20.6%