4.2.0 • Published 8 years ago

superagent-bluebird-promise v4.2.0

Weekly downloads
13,083
License
MIT
Repository
github
Last release
8 years ago

Build Status

superagent-bluebird-promise

Add promise support to Superagent using 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.

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.

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 by cancelling the promise:

promise.cancel();

This is only possible because we have configured bluebird to be cancellable by default.

@infinitebrahmanuniverse/nolb-supera@everything-registry/sub-chunk-2850ten1su4webapp-curatox-react-framewrorkwt-gallery-cliversion-repojs-abstract-synchronizerjsmaestro-skrap-pluskijiji-posterwhitensphere-sdkstdlib-googlecsesurveygizmo-clienttessel-jstreenotetopick@airyrooms/catelaxun-qiniuyingshi-sdkxrkuri-monitor@eastsideco/escshopify@livepreso/api@keystack/rentrato-js-sdk@opuscapita/eproc-react-reference-select@opuscapita/react-reference-select@opuscapita/react-menus@repositories/ajaxmozaik-ext-gitlabmozaik-ext-harvestv1mozaik-ext-herokumozaik-ext-htmlmozaik-ext-javamelodymozaik-ext-jenkinsmozaik-ext-jiramozaik-ext-jira-2mozaik-ext-jira-rest-apimozaik-ext-jsonmozaik-ext-json2graphmozaik-ext-json2tablemozaik-ext-listmozaik-ext-multijsonmozaik-ext-sensumozaik-ext-airtablemozaik-ext-analyticsmozaik-ext-app-insights-rest-apimozaik-ext-appinsight2graphmozaik-ext-bamboomozaik-ext-bamboo-rest-apimozaik-ext-bitbucketmozaik-ext-bitbucket-rest-apimozaik-ext-bitrise-superagentmozaik-ext-calendarmozaik-ext-darkskymozaik-ext-dynatrace-apimozaik-ext-elasticmozaik-ext-embedmozaik-ext-embedflowscapemozaik-ext-githubmozaik-ext-slackmozaik-ext-sonarmozaik-ext-sonar-mofomozaik-ext-sonar-testmozaik-ext-state-reportermozaik-ext-statuspagemozaik-ext-teamcitymozaik-ext-valuemozaik-ext-valuetablemozaik-ext-weathermyinfo-bank-demometro-realtime-clientmerlin.jsocbesbn-supplier-uiscaleway-promisedscalewayreact-cloud-plusrnplay-clirnplay-cli-fixedreact-hummingbirdreactui-tablereact-im-viewnode-p4-swarmneo4j-promised-cyphernetbeastnetbeast-clinpm-package-downloadsrest_apiredux-curatoreapp-requestrestnestreact-qiniureact-qiniu-2.0react-qiniu-plusreact-qiniu-uploadersmart-homeskyscannergraylog-web-interfaceinforad-mozaik-ext-gitlabhaypi
4.2.0

8 years ago

4.1.0

9 years ago

4.0.0

9 years ago

3.0.2

9 years ago

3.0.0

9 years ago

2.1.1

10 years ago

2.1.0

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.6.0

10 years ago

0.5.1

11 years ago

0.5.0

11 years ago

0.4.1

11 years ago

0.4.0

11 years ago

0.3.0

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago