# fetchagent

> Flex API for global fetch

Latest version **3.0.0** (published 2025-05-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install fetchagent
pnpm add fetchagent
yarn add fetchagent
bun add fetchagent
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2025-05-13 |
| First published | 2016-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Damian Krzeminski |
| Maintainers | pirxpilot |
| Keywords | fetchagent, fetch, get, superagent, ajax, xmlhttprequest |

## Links

- npm: https://www.npmjs.com/package/fetchagent
- Repository: https://github.com/pirxpilot/fetchagent
- Homepage: https://github.com/pirxpilot/fetchagent#readme
- Issues: https://github.com/pirxpilot/fetchagent/issues
- npm.io page: https://npm.io/package/fetchagent

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2025-05-13
- 2.1.1 — 2024-01-23
- 2.1.0 — 2022-09-07
- 2.0.2 — 2022-01-29
- 2.0.1 — 2022-01-29
- 2.0.0 — 2019-02-02
- 1.1.3 — 2018-03-24
- 1.1.2 — 2017-05-14
- 1.1.1 — 2017-04-11
- 1.1.0 — 2017-04-11
- 1.0.3 — 2017-02-19
- 1.0.2 — 2017-01-27
- 1.0.1 — 2017-01-26
- 1.0.0 — 2016-12-28
- 0.0.0 — 2016-12-28

## README

[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Dependency Status][deps-image]][deps-url]

# fetchagent

Flex API for global fetch

## Install

```sh
$ npm install --save fetchagent
```

## Usage

```js
var fa = require('fetchagent');


// using callbacks
fa
  .get('http://httpbin.org/xml')
  .end(function(err, response) {
    if (err) {
      console.log(err, status);
    }
    console.log("Received:", response);
  });

// using promises
fa
  .post('http://httpbin.org/post')
  .send({ echo: 42 })
  .json()
  .then(function(response) {
    console.log("Received:", response.echo);
  });

```

# API

To configure request use one or more:

- `get(url)`, `put(url)`, `post(url)`, `delete(url)` - HTTP method to `url`
- `query()` - sets search params (a.k.a querystring)
- `set(name, vale)` - sets header `name` to `value`
- `set(obj)` - sets headers for all properties of the `object`
- `redirect(flag)` - pass truthy value if fetchagent is supposed to automatically handle redirects

To send request use on of:

- `end(callback)` - pass `callback(err, body)`
- `end()` - returns a Promise that resolves to a response
- `json()` - returns a Promise resolving to a parsed object
- `text()` - returns a Promise resolving to a body text

## License

MIT © [Damian Krzeminski](https://pirxpilot.me)

[npm-image]: https://img.shields.io/npm/v/fetchagent
[npm-url]: https://npmjs.org/package/fetchagent

[build-url]: https://github.com/pirxpilot/fetchagent/actions/workflows/check.yaml
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/fetchagent/check.yaml?branch=main

[deps-image]: https://img.shields.io/librariesio/release/npm/fetchagent
[deps-url]: https://libraries.io/npm/fetchagent

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