1.1.0 • Published 3 years ago

fth v1.1.0

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

fth

npm MIT License

fetch that just works on any modern environments

fth is a CommonJS module which exports fetch. It uses node-fetch on Node.js and native fetch on any other environments (e.g. browsers and Deno).

Note that this module does not include fetch polyfill/ponyfill for legacy browsers.

Supported environments

  • Node.js (via node-fetch)
  • Modern browsers and Deno (in particular, any environments which imprement fetch)

Example

Node.js

const fetch = require('fth')
const { Response } = fetch

const main = async () => {
  const resp = await fetch('https://example.com/')

  console.log(resp instanceof Response)
  console.log(await resp.text())
}

main()

Deno

import fetch, { Response } from 'https://esm.sh/fth'

const resp = await fetch('https://example.com/')

console.log(resp instanceof Response)
console.log(await resp.text())
1.1.0

3 years ago

1.0.0

3 years ago

1.0.0-alpha.0

3 years ago