# superagent-promise-plugin

> Plugin for visionmedia/superagent. Use req.then or req['catch'] to execute your request and handle via promises.

Latest version **3.2.0** (published 2016-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install superagent-promise-plugin
pnpm add superagent-promise-plugin
yarn add superagent-promise-plugin
bun add superagent-promise-plugin
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.2.0 |
| Published | 2016-04-16 |
| First published | 2015-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 29 |
| Author | Josef Blake |
| Maintainers | joblake07 |
| Keywords | superagent, superagent-promise, superagent-promise-plugin, promise, plugin |

## Links

- npm: https://www.npmjs.com/package/superagent-promise-plugin
- Repository: https://github.com/jomaxx/superagent-promise-plugin
- Issues: https://github.com/jomaxx/superagent-promise-plugin/issues
- npm.io page: https://npm.io/package/superagent-promise-plugin

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 3.2.0 (latest) — 2016-04-16
- 3.1.0 — 2016-03-25
- 3.0.0 — 2016-03-25
- 2.2.0 — 2016-03-25
- 2.1.0 — 2016-02-17
- 2.0.0 — 2015-12-12
- 1.0.1 — 2015-02-19

## README

# superagent-promise
Plugin for [`visionmedia/superagent`](https://github.com/visionmedia/superagent). Use `req.then` or `req['catch']` to execute your request and handle via promises.

## Install
```
npm install superagent superagent-promise-plugin --save
```

## How to use
Requires ES6 Promises. Polyfill or set `superagentPromisePlugin.Promise` with [`es6-promise`](https://github.com/jakearchibald/es6-promise) or equivalent.

```js
var request = require('superagent');
var superagentPromisePlugin = require('superagent-promise-plugin');

superagentPromisePlugin.Promise = require('es6-promise');

request.get('/end/point')
  .use(superagentPromisePlugin)
  .then(function (res) {
    // success
  })
  .catch(function (err) {
    // error
    var res = err.response; // the full response object
  });
```

## Patching superagent
Patch the `superagent` module so that every request has `req.then` and `req['catch']` methods.

```js
require('es6-promise').polyfill();
var superagentPromisePlugin = require('superagent-promise-plugin');
var request = superagentPromisePlugin.patch(require('superagent'));

request.get('/end/point')
  .then(function (res) {
    // success
  })
  .catch(function (err) {
    // error
  });
```

## License
[MIT](LICENSE)

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