Skip to content

isNotOkay/request-promise-batch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Request-Promise-Batch

Utility to create reusable HTTP-requests and execute them in serial, using the full power of request-promise.

Installation

npm install request-promise-batch

Usage

var RequestPromiseBatch = require('request-promise-batch');

var config = {
    postOptions: {
        uri: 'http://posttestserver.com/post.php'
    }
};

var request = new RequestPromiseBatch(config);

// create reusable POST/GET/PUT/DELETE-requests ...
var getGoogle = request.createGetRequest('http://www.google.de');
var getWikipedia = request.createGetRequest('http://www.wikipedia.de');
var getReddit = request.createGetRequest('http://www.reddit.org');

// ... and execute them in isolation ...
getGoogle().then(function (res) {
    console.log('=== got google ===' + res.statusCode);
});

// ... or as a batch-Request in serial.
var getSome = request.createBatchRequest([getGoogle, getWikipedia, getReddit]);
getSome().then(function (res) {
    console.log('=== got google, wikipedia and reddit ===');
    console.log(res);
});

// bonus: batch-Requests can also be combined with regular requests
var getYahoo = request.createGetRequest('http://www.yahoo.com');
var getThemAll = request.createBatchRequest([getSome, getYahoo]);
getThemAll().then(function (res) {
    console.log('=== got them all ===');
    console.log(res);
});

API

Coming soon. ;)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published