# @glomex/custom-fetch

> A convenience wrapper for fetch, which can be used in node and in the browser.

Latest version **1.1.3** (published 2022-01-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @glomex/custom-fetch
pnpm add @glomex/custom-fetch
yarn add @glomex/custom-fetch
bun add @glomex/custom-fetch
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2022-01-25 |
| First published | 2021-11-30 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 3.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | glomex GmbH |
| Maintainers | dvselas, defly, alexnick, klipstein, maxbanton, okinash, hrb-d, glomex-all-the-things, xazzzi, nerdbeere, diablero13 |

## Links

- npm: https://www.npmjs.com/package/@glomex/custom-fetch
- Repository: https://github.com/glomex/custom-fetch
- Homepage: https://github.com/glomex/custom-fetch#readme
- Issues: https://github.com/glomex/custom-fetch/issues
- npm.io page: https://npm.io/package/@glomex/custom-fetch

## Dependencies (2)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.7
- [abort-controller](https://npm.io/package/abort-controller.md) ^3.0.0

## Recent versions

- 1.1.3 (latest) — 2022-01-25
- 1.1.2 — 2021-12-01
- 1.1.1 — 2021-12-01
- 1.1.0 — 2021-12-01
- 1.0.7 — 2021-11-30
- 1.0.6 — 2021-11-30
- 1.0.4 — 2021-11-30
- 1.0.3 — 2021-11-30
- 1.0.2 — 2021-11-30
- 1.0.1 — 2021-11-30
- 1.0.0 — 2021-11-30

## README

# @glomex/custom-fetch

A convenience wrapper for fetch, which can be used in node and in the browser.

### It handles the following things:

- Automatically assumes that `Content-Type': application/json` is used (encodes body with `JSON.stringify` and automatically resolves the response with `.json()`)
- Allows to pass a timeout

### Usage

#### Node

It ensures to load `node-fetch` and `abort-controller` as necessary.

```js
const fetch = require('@glomex/custom-fetch');
fetch(
  'https://my-endpoint',
  // also see https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters
  { method: 'GET' },
  { timeout: 5000 }
);
```

#### Browser

```js
import fetch from 'https://unpkg.com/@glomex/custom-fetch@1/dist/custom-fetch.modern.js';
fetch(
  'https://my-endpoint',
  // also see https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters
  { method: 'GET' },
  { timeout: 5000, responseType: 'text' }
);
```

## License

[Apache 2.0 License](https://oss.ninja/apache-2.0-header/glomex)

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