https://github.com/ciffelia/fth
fetch that just works on any modern environments
https://github.com/ciffelia/fth
deno fetch javascript nodejs
Last synced: about 2 months ago
JSON representation
fetch that just works on any modern environments
- Host: GitHub
- URL: https://github.com/ciffelia/fth
- Owner: ciffelia
- License: mit
- Created: 2021-09-20T07:39:56.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-23T14:09:16.000Z (almost 5 years ago)
- Last Synced: 2025-02-19T11:50:56.154Z (over 1 year ago)
- Topics: deno, fetch, javascript, nodejs
- Language: JavaScript
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fth
[](https://www.npmjs.com/package/fth)
[](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](https://github.com/node-fetch/node-fetch))
- Modern browsers and Deno (in particular, any environments which imprement [`fetch`](https://caniuse.com/fetch))
## Example
### Node.js
```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
```js
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())
```