webclient

1.0.2 • Public • Published

webclient

npm install --save webclient

API

var req = new WebClient();
req.get(opts) -> Promise(result <- [response, body])
req.post(opts) -> Promise(result <- [response, body])

opts.method <- defaults to GET
opts.url <- http://google.com
opts.qs <- query string - object {name: value}
opts.form <- form data - object {name: value}
opts.jar <- tough-cookie-filestore, mongo-cookie-monster, redis-cookie-monster or any other compatible module
opts.timeout <- in ms - defaults to 30000
opts.followRedirect <- bool - defaults to true
opts.gzip <- bool
opts.proxy <- proxy ip:port format
opts.localAddress <- bind ip address
opts.headers <- object {headerName: headerValue}

Examples

You can find more wild examples in /tests folder

var WebClient = require('../');

WebClient.get({
    url: 'http://mail.yahoo.com'
}).then(function(result) {
    let response = result[0], body = result[1];
    response.body = body.length;
    // console.log(response);

    console.log(response);
}).catch(function(err) {
    console.log(err.stack);
});

Package Sidebar

Install

npm i webclient

Weekly Downloads

48

Version

1.0.2

License

MIT

Last publish

Collaborators

  • nytr0gen