fth
v1.1.0
Published
fetch that just works on any modern environments
Downloads
4
Readme
fth
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())