Skip to content

zurfyx/superagent-absolute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Superagent Absolute

Superagent with default absolute URLs.

Build Status npm version

Tired of writing http://localhost in front of every superagent request? With superagent absolute you'll only write it once per host in your whole environment.

Install

npm install superagent-absolute

Usage

var superagent = require('superagent');
var superagentAbsolute = require('superagent-absolute');

var agent = superagent.agent();
global.request = superagentAbsolute(agent)('http://localhost:3030');

Example

const superagent = require('superagent');
const superagentAbsolute = require('superagent-absolute');

const agent = superagent.agent();
const request = superagentAbsolute(agent)('http://localhost:3030');

it('should should display "It works!"', (done) => {
  request
    .get('/')
    .end((err, res) => {
      expect(res.status).to.equal(200);
      expect(res.body).to.eql({ msg: 'It works!' });
      done();
    });
});

Requested absolute URLs must start with /, otherwise they will be treated as relative.

Related

License

MIT © Gerard Rovira Sánchez

About

Superagent with default absolute URLs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published