Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

superagent-promise

1.1.0 • Public • Published

Build Status

superagent-promise

Simple/dumb promise wrapper for superagent. You must depend on superagent and your favorite Promise library directly.

Usage

var Promise = this.Promise || require('promise');
var agent = require('superagent-promise')(require('superagent'), Promise);
 
// method, url form with `end`
agent('GET', 'http://google.com')
  .end()
  .then(function onResult(res) {
    // do stuff
  }, function onError(err) {
    //err.response has the response from the server
  });
 
// method, url form with `then`
agent('GET', 'http://google.com')
  .then(function onResult(res) {
    // do stuff
  });
 
 
// helper functions: options, head, get, post, put, patch, del
agent.put('http://myxfoo', 'data')
  .end()
  .then(function(res) {
    // do stuff`
  });
 
// helper functions: options, head, get, post, put, patch, del
agent.put('http://myxfoo', 'data').
  .then(function(res) {
    // do stuff
  });
 
 

install

npm i superagent-promise

Downloadsweekly downloads

10,337

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability