Have ideas to improve npm?Join in the discussion! »

    request-persistent

    1.0.1 • Public • Published

    request-persistent

    A simple module to add a toJSON function and a fromJSON function to cookie jars created with request.jar().

    usage

    var fs = require('fs');
    var request('request');
    require('request-persistent')(request);
    var jar;
    if (fs.existsSync('cookies.json')) {
      jar = request.jar.fromJSON(fs.readFileSync('cookies.json'));
      // can also be an object, request.jar.fromJSON(require('./cookies')) would work
    } else {
      jar = request.jar();
    }
    request({
      jar: jar
      method: 'POST',
      url: 'http://website.com/login',
      form: {
        user: 'username',
        pass: 'password'
      },
    }, function (err, resp, body) {
      fs.writeFileSync('cookies.json', jar.toJSON());
    });
    

    Install

    npm i request-persistent

    DownloadsWeekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • avatar