Package Exports
- superagent-absolute
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (superagent-absolute) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Superagent Absolute
Superagent with default absolute URLs.
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-absoluteUsage
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.
License
MIT © Gerard Rovira Sánchez