Socket
Socket
Sign inDemoInstall

superagent-promise-plugin

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

superagent-promise-plugin

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


Version published
Weekly downloads
4.4K
increased by9.64%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

superagent-promise

Plugin for 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 or equivalent.

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.

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

Keywords

FAQs

Package last updated on 16 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc