4.2.0 • Published 7 years ago

superagent-bluebird-promise v4.2.0

Weekly downloads
13,083
License
MIT
Repository
github
Last release
7 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-2850js-abstract-synchronizergraylog-web-interfacejsmaestro-skrap-plushydra-dashhydra-dash-ext-generichaypilneves-cli-testinforad-mozaik-ext-gitlableanplum-node-wrapper@eastsideco/escshopifywhitenevalinegxofast-release-notesgeocodecode-kingocbesbn-supplier-uikijiji-posternode-p4-swarmnpm-package-downloadsneo4j-promised-cyphermyinfo-bank-demonetbeastnetbeast-climozaik-ext-airtablemozaik-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-slackmozaik-ext-sonarmozaik-ext-sonar-mofomozaik-ext-sonar-testmozaik-ext-state-reportermozaik-ext-statuspagemozaik-ext-teamcitymozaik-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-gitlabmozaik-ext-harvestv1mozaik-ext-herokumozaik-ext-htmlmozaik-ext-valuemozaik-ext-valuetablemozaik-ext-weathermetro-realtime-clientmerlin.jsreact-im-viewreact-hummingbirdreact-cloud-plusreact-qiniu-plusreact-qiniu-uploaderreact-qiniureact-qiniu-2.0scalewayscaleway-promisedreapp-requestreactui-tableredux-curatorest_apirestnestrnplay-clirnplay-cli-fixedtessel-jstopickstdlib-googlecseskyscannersmart-homesphere-sdktreenotesurveygizmo-clientten1su4yingshi-sdkuri-monitorversion-repowebapp-curatox-react-framewrorkxrkxun-qiniu
4.2.0

7 years ago

4.1.0

8 years ago

4.0.0

8 years ago

3.0.2

8 years ago

3.0.0

8 years ago

2.1.1

8 years ago

2.1.0

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.6.0

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago