Skip to content

An enhancement to mikeal/request library to create reusuable clients that supports cookies per client

License

Notifications You must be signed in to change notification settings

sharathprabhal/request-with-cookies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

request-with-cookies

NPM

Build Status

An enhancement to mikeal/request library to create reusuable clients that supports cookies per client

Usage

Create a new client and use the same API as mikeal/request

var request = require("request-with-cookies");
var client = request.createClient();
client("http://www.google.com", function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) // Prints the google web page.
  }
});

You can also create a client with baked in options

var request = require("request-with-cookies");
var options = {
  qs: {
    q: "foo"
  }
};

var client = request.createClient(options);
// now every request will be sent with "?q=foo" appended to the URL
client("http://www.google.com", function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) // Prints the google web page.
  }
});

Custom cookies can be set by passing in the following options

var options = {
  url: "https://foobar.com",
  cookies: [
  	{
  	  name: "foo",
  	  value: "v1"
  	},
  	{
  	  name: "bar",
  	  value: "v2"
  	}
  ]
};

Build and Test

The code can be built using gulp as follows

$ gulp 

Run tests using

$ npm test

About

An enhancement to mikeal/request library to create reusuable clients that supports cookies per client

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published