Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

azuqua/superagent-defaults

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

superagent-defaults Build Status

Create some defaults for superagent requests

Usage

var defaults = require('superagent-defaults');

// Create a defaults context
var superagent = defaults();

// Setup some defaults
superagent
  .set('my-default-header', 'my-default-value')
  .auth('myUsername', 'myPassword')
  .on('request', function (req) {
    console.log(req.url);
  });

// Use superagent like you always have; the defaults will be applied to
// each request automatically
superagent
  .get('/my-api')
  .end(function(res) {
    console.log(res.text);
  });

You may also pass a function that implements the superagent interface.

var defaults = require('superagent-defaults');
var supertest = require('supertest');

var request = defaults(supertest(app));

request
  .get('/my-test-path')
  .end(function(err, res) {
    console.log(res.text);
  });

Tests

$ npm test

About

Create some defaults for superagent requests

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%