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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?