0.1.0 • Published 2 years ago

node-fetch-compat v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

node-fetch-compat

bundle size

A redistribution of node-fetch (latest, v3) for better compatibility:

✅ Prefer to native globals when available (fetch, Blob, FormData, Headers, Request, Response)

✅ Compact build and less install size with zero dependencies

✅ Allow both CommonJS (require) and ESM (import) usage

✅ Automatically use zero-overhead native wrappers if imported without node condition (for Browseers) using export conditions

Usage

Install node-fetch-compat dependency:

# npm
npm i node-fetch-compat

# yarn
yarn add node-fetch-compat

# pnpm
pnpm i node-fetch-compat

You can now either import or require the dependency:

// ESM
import fetch from `node-fetch-compat`

// CommonJS
const fetch = require('node-fetch-compat')

Other exports:

// ESM
import { fetch, Blob, FormData, Headers, Request, Response } from `node-fetch-compat`

// CommonJS
const { fetch, Blob, FormData, Headers, Request, Response } = require('node-fetch-compat')

License

MIT