superagent-promise

Simple/dumb promise wrapper for superagent

  • 所有者: lightsofapollo/superagent-promise
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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
  });

Mocking

Now superagent-promise can be mocked using superagent-mock. For the complete example see
test/mock.spec.js and test/mock.config.js.

var SUCCESS_BODY = 'Yay! Mocked :)';
var mockedRequest = require('superagent');
var mocks = require('./mock.config')('localhost', SUCCESS_BODY);
require('superagent-mock')(mockedRequest, mocks);
var request = require('../index')(mockedRequest, Promise);

主要指标

概览
名称与所有者lightsofapollo/superagent-promise
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2014-01-28 10:50:27
推送于2018-06-04 14:36:25
最后一次提交2018-06-04 07:36:24
发布数7
最新版本名称v1.1.0 (发布于 2015-12-22 17:38:25)
第一版名称0.1.0 (发布于 )
用户参与
星数129
关注者数1
派生数27
提交数43
已启用问题?
问题数14
打开的问题数5
拉请求数9
打开的拉请求数2
关闭的拉请求数4
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?