# advanced-fetch

> A version of node-fetch with more convenient functionality.

Latest version **3.1.2** (published 2023-02-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install advanced-fetch
pnpm add advanced-fetch
yarn add advanced-fetch
bun add advanced-fetch
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.2 |
| Published | 2023-02-01 |
| First published | 2020-11-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 28.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | sigalor |
| Maintainers | sigalor |

## Links

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

## Dependencies (6)

- [fs-extra](https://npm.io/package/fs-extra.md) ^11.1.0
- [form-data](https://npm.io/package/form-data.md) ^4.0.0
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.6.3
- [fetch-cookie](https://npm.io/package/fetch-cookie.md) ^2.1.0
- [tough-cookie](https://npm.io/package/tough-cookie.md) ^4.1.2
- [node-fetch-commonjs](https://npm.io/package/node-fetch-commonjs.md) ^3.2.4

## Recent versions

- 3.1.2 (latest) — 2023-02-01
- 3.1.1 — 2023-01-10
- 3.1.0 — 2023-01-10
- 3.0.0 — 2023-01-10
- 2.2.1 — 2023-01-10
- 2.2.0 — 2023-01-10
- 2.1.0 — 2023-01-10
- 1.1.0 — 2021-08-24
- 1.0.1 — 2020-11-01
- 1.0.0 — 2020-11-01

## README

# advanced-fetch

[![GitHub license](https://img.shields.io/github/license/sigalor/advanced-fetch)](https://github.com/sigalor/advanced-fetch/blob/master/LICENSE) [![npm](https://img.shields.io/npm/v/advanced-fetch)](https://www.npmjs.com/package/advanced-fetch) [![Unit tests workflow status](https://github.com/sigalor/advanced-fetch/actions/workflows/tests.yaml/badge.svg)](https://github.com/sigalor/advanced-fetch/actions/workflows/tests.yaml)

A version of node-fetch with more convenient functionality.

## Installation

```
npm install advanced-fetch
```

## Usage

```javascript
const { Fetch } = require("advanced-fetch");

(async () => {
  const fetch = new Fetch();
  await fetch.get("http://example.com");
  // subsequent requests to example.com now send the received
  // cookies again, and the cookies are updated automatically
})();
```

## Constructor

The `Fetch` constructor expects an optional object, with the following possible attributes:

- `cookiesFilename`: If given, the [tough-cookie](https://www.npmjs.com/package/tough-cookie) cookie jar is serialized into JSON after each request and that JSON is written into the specified file.
- `encoding`: If given, the received responses are assumed to be in that text encoding and converted automatically to UTF-8 via [iconv-lite](https://www.npmjs.com/package/iconv-lite) before they are returned to you.

## Request parameters

Supports `.get`, `.post`, `.put` and `.delete`. After the URL, all of these functions also expect an optional object with [node-fetch](https://www.npmjs.com/package/node-fetch) request parameters.

Additionally, you can specify the following parameters as normal JavaScript objects, which are serialized respectively automatically:

- `query` for GET query parameters, internally serialized using [querystring](https://nodejs.org/api/querystring.html)
- `form` for the body of a `Content-Type: application/x-www-form-urlencoded` request, internally serialized using [URLSearchParams](https://nodejs.org/api/url.html#url_class_urlsearchparams)
- `formData` for the body of a `Content-Type: multipart/form-data` request, internally serialized using [form-data](https://www.npmjs.com/package/form-data)
- `json` for the body of a `Content-Type: application/json` request, internally serialized using `JSON.stringify`

Finally, you can specify `returnBuffer: true` in the parameters object in order to get a Node.js `Buffer` as the result of a request instead of a string.

## License

MIT

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