# superagent-bluebird-promise

> Add promise support to superagent using Bluebird

Latest version **4.2.0** (published 2017-02-27) · MIT license · 0 weekly downloads

## Install

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

## 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 | 4.2.0 |
| Published | 2017-02-27 |
| First published | 2014-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 180 |
| Author | Kyle Mathews |
| Maintainers | bmv437, kylemathews, markdalgleish |
| Keywords | superagent, promise, bluebird |

## Links

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

## 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

- 4.2.0 (latest) — 2017-02-27
- 4.1.0 — 2016-10-02
- 4.0.0 — 2016-09-14
- 3.0.2 — 2016-06-28
- 3.0.0 — 2016-01-08
- 2.1.1 — 2015-11-20
- 2.1.0 — 2015-08-21
- 2.0.2 — 2015-04-21
- 2.0.1 — 2015-04-15
- 2.0.0 — 2015-03-18
- 1.1.1 — 2015-03-08
- 1.1.0 — 2015-03-05
- 1.0.1 — 2015-03-03
- 1.0.0 — 2015-03-02
- 0.6.0 — 2015-01-14
- … 7 more at https://npm.io/package/superagent-bluebird-promise/versions

## README

[![Build Status](https://img.shields.io/travis/KyleAMathews/superagent-bluebird-promise/master.svg?style=flat-square)](http://travis-ci.org/KyleAMathews/superagent-bluebird-promise)

superagent-bluebird-promise
===========================

Add promise support to
[Superagent](http://visionmedia.github.io/superagent/) using
[Bluebird](https://github.com/petkaantonov/bluebird).

## Install
`npm install superagent-bluebird-promise`

## Usage
Simply require this package instead of `superagent`. Then you can call `.then()` or `.catch()` instead of `.end()` to get a promise for your requests.

```javascript
var request = require('superagent-bluebird-promise');

// .then()
request.get('/an-endpoint')
  .then(function(res) {
    console.log(res);
  }, function(error) {
    console.log(error);
  });

// .catch()
request.get('/an-endpoint')
  .catch(function(error) {
    console.log(error);
  });
```

To generate a promise without registering any callbacks (e.g. when returning a promise from within a library), call `.promise()` instead.

```javascript
request.get('/an-endpoint').promise()
```

In order to use any of Bluebird's various promise methods, make sure you call `.then()` or `.promise()` first.

An error is thrown for all HTTP errors and responses that have a response code of 400 or above.

The `error` parameter always has a key `error` and for 4xx and 5xx responses, will also have a `status` and `res` key.

## Cancelling requests

You can [abort the request](http://visionmedia.github.io/superagent/#aborting-requests) by [cancelling the promise](https://github.com/petkaantonov/bluebird/blob/master/API.md#cancelerror-reason---promise):

```js
promise.cancel();
```

This is only possible because  we have configured bluebird to be [cancellable](http://bluebirdjs.com/docs/api/promise.config.html) by default.

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