# native-browser-fetch

> Returns native fetch if available or the node-fetch module if not

Latest version **0.0.1** (published 2020-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install native-browser-fetch
pnpm add native-browser-fetch
yarn add native-browser-fetch
bun add native-browser-fetch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2020-08-28 |
| First published | 2020-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Alex Potsides |
| Maintainers | achingbrain |

## Links

- npm: https://www.npmjs.com/package/native-browser-fetch
- Repository: https://github.com/achingbrain/native-fetch
- Homepage: https://github.com/achingbrain/native-fetch#readme
- Issues: https://github.com/achingbrain/native-fetch/issues
- npm.io page: https://npm.io/package/native-browser-fetch

## Recent versions

- 0.0.1 (latest) — 2020-08-28

## README

# native-fetch

> Returns native fetch/Request/Headers if available or the node-fetch module if not

A drop-in replacement for the `node-fetch` module that returns the native fetch if available or the polyfill if not.

### Why?

Some environments such as the Electron Renderer process straddle the node/browser divide with features from both APIs available.  In these cases the webpack approach of always using the `browser` field in your `package.json` to override requires is too heavy-handed as sometimes you want to use the node version of an API.

Instead we can check for the availability of a given API and return it, rather than the node-polyfill for that API.

## Install

You must install a version of `node-fetch` [alongside this module](https://docs.npmjs.com/files/package.json#peerdependencies) to be used if a native implementation is not available.

```console
$ npm install --save native-fetch node-fetch
```

## Usage

```javascript
const fetch = require('native-fetch')

fetch('https://github.com/')
    .then(res => res.text())
    .then(body => console.log(body))
```

---
_Source: https://npm.io/package/native-browser-fetch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
