How to use the request.bind function in request

To help you get started, we’ve selected a few request examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github garbados / quilter / test / pull / index.js View on Github external
beforeEach(function (done) {
    this.mount = 'derp';
    this.remote = 'http://localhost:5984/quilt_test';
    this.config_path = './derp_config.json';

    async.series([
      // create the local folder
      fs.mkdir.bind(fs, this.mount),
      // create the remote db
      request.bind(request, {
        method: 'PUT',
        url: this.remote
      }),
      // put a doc into the remote
      request.bind(request, {
        method: 'POST',
        url: this.remote,
        json: {
          _id: 'test.md',
          hash: 'whatever man just whatever',
          _attachments: {
            file: {
              content_type: 'text/plain',
              data: new Buffer('# hello world').toString('base64')
            }
          }
        }
      })
    ], done);
  });
github garbados / quilter / test / push / index.js View on Github external
it('should delete a doc', function (done) {
      var self = this;
      async.series([
        request.bind(request, {
          url: this.remote,
          method: 'POST',
          json: {
            _id: 'test.md',
            hash: 'blow me up!'
          }
        }),
        quilter.push.destroy.bind(this, 'test.md'),
        request.get.bind(request, [this.remote, 'test.md'].join('/'))
      ], function (err, res) {
        assert(!err);
        var status_code = res[2][0].statusCode;
        assert.equal(status_code, 404);
        done();
      });
    });
github garbados / quilter / test / e2e / index.js View on Github external
beforeEach(function (done) {
      async.parallel([
        fs.writeFile.bind(fs, this.quilt.util.file.path('other.md'), '# hello world'),
        request.bind(request, {
          method: 'POST',
          url: this.remote,
          json: {
            _id: 'test.md',
            hash: 'whatever man just whatever',
            _attachments: {
              file: {
                content_type: 'text/plain',
                data: new Buffer('# good bye').toString('base64')
              }
            }
          }
        })
      ], done);
    });
github garbados / quilter / test / pull / index.js View on Github external
afterEach(function (done) {
    async.series([
      request.bind(request, {
        url: this.remote,
        method: 'DELETE'
      }),
      quilter.util.rmdir.bind(null, this.mount)
    ], function (err) {
      done(err);
    });
  });
});
github garbados / quilter / test / docs / remote.js View on Github external
before(function (done) {
    this.remote = 'http://localhost:5984/quilt_test';
    this.mount = './derp';
    this.doc_id = 'test.md';

    async.parallel([
      async.series.bind(async, [
        fs.mkdir.bind(fs, this.mount),
        fs.writeFile.bind(fs, path.join(this.mount, this.doc_id), '# hello world')
      ]),
      request.bind(request, {
        url: this.remote,
        method: 'PUT'
      })
    ], done);
  });
github garbados / quilter / test / push / index.js View on Github external
afterEach(function (done) {
    async.series([
      request.bind(request, {
        url: this.remote,
        method: 'DELETE'
      }),
      quilter.util.rmdir.bind(null, this.mount)
    ], done);
  });
});