SuperAgent is a small progressive client-side HTTP request library, and Node.js module with the same API, sporting many high-level HTTP client features. View the docs.
FORK this fork removes the suck introduced into superagent 1.x by returning the end
api back to being compliant with node-style callback conventions as in the original superagent 0.x design. This fork will track official releases of superagent so everyone can benefit from improvements in superagent. The goal is merge this fork back into superagent and to retire this fork.
node:
$ npm install superagent-ls
component:
$ component install kmalakoff/superagent-ls
Works with browserify and should work with webpack
request
.post('/api/pet')
.send({ name: 'Manny', species: 'cat' })
.set('X-API-Key', 'foobar')
.set('Accept', 'application/json')
.end(function(err, res){
});
Tested browsers:
- Latest Android
- Latest Firefox
- Latest Chrome
- IE9 through latest
- Latest iPhone
- Latest Safari
Even though IE9 is supported, a polyfill window.btoa
is needed to use basic auth.
Superagent is easily extended via plugins.
var nocache = require('no-cache');
var request = require('superagent-ls');
var prefix = require('superagent-prefix')('/static');
prefix(request); // Prefixes *all* requests
request
.get('/some-url')
.use(nocache) // Prevents caching of *only* this request
.end(function(res){
// Do something
});
Existing plugins:
- superagent-no-cache - prevents caching by including Cache-Control header
- superagent-prefix - prefixes absolute URLs (useful in test environment)
Please prefix your plugin with superagent-*
so that it can easily be found by others.
For superagent extensions such as couchdb and oauth visit the wiki.
Install dependencies:
$ npm install
Run em!
$ make test
Install dependencies:
$ npm install
Start the test runner:
$ make test-browser-local
Visit http://localhost:4000/__zuul
in your browser.
Edit tests and refresh your browser. You do not have to restart the test runner.
MIT