Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 110 lines (75 sloc) 2.729 kB
2624761 @defunctzombie add build status badge
defunctzombie authored
1 # SuperAgent [![Build Status](https://travis-ci.org/visionmedia/superagent.svg?branch=master)](https://travis-ci.org/visionmedia/superagent)
f808b57 @tj Initial commit
tj authored
2
be0e0b3 @defunctzombie add saucelabs browser badge to readme
defunctzombie authored
3 [![Sauce Test Status](https://saucelabs.com/browser-matrix/shtylman-superagent.svg)](https://saucelabs.com/u/shtylman-superagent)
4
f46fadd @defunctzombie update README
defunctzombie authored
5 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](http://visionmedia.github.com/superagent/).
f808b57 @tj Initial commit
tj authored
6
f310123 @tj the new face of superagent
tj authored
7 ![super agent](http://f.cl.ly/items/3d282n3A0h0Z0K2w0q2a/Screenshot.png)
8
3f8ffce @tj Update Readme.md
tj authored
9 ## Installation
10
f46fadd @defunctzombie update README
defunctzombie authored
11 node:
3f8ffce @tj Update Readme.md
tj authored
12
13 ```
14 $ npm install superagent
15 ```
16
f46fadd @defunctzombie update README
defunctzombie authored
17 component:
3f8ffce @tj Update Readme.md
tj authored
18
19 ```
20 $ component install visionmedia/superagent
21 ```
22
f46fadd @defunctzombie update README
defunctzombie authored
23 Works with [browserify](https://github.com/substack/node-browserify) and should work with [webpack](https://github.com/visionmedia/superagent/wiki/Superagent-for-Webpack)
f808b57 @tj Initial commit
tj authored
24
25 ```js
26 request
27 .post('/api/pet')
6dcc9b2 @tj docs
tj authored
28 .send({ name: 'Manny', species: 'cat' })
f808b57 @tj Initial commit
tj authored
29 .set('X-API-Key', 'foobar')
d2c189f @tj docs
tj authored
30 .set('Accept', 'application/json')
f46fadd @defunctzombie update README
defunctzombie authored
31 .end(function(err, res){
711c3a5 @laurilehmijoki Explain what the end function does
laurilehmijoki authored
32 // Calling the end function will send the request
f808b57 @tj Initial commit
tj authored
33 });
34 ```
35
ab80d39 @rase- Added supported browsers readme section
rase- authored
36 ## Supported browsers
37
38 Tested browsers:
39
40 - Latest Android
41 - Latest Firefox
42 - Latest Chrome
43 - IE9 through latest
44 - Latest iPhone
45 - Latest Safari
46
47 Even though IE9 is supported, a polyfill `window.btoa` is needed to use basic auth.
48
ca4ddc6 Clean up plugin section on the readme
Garrett Johnson authored
49 # Plugins
50
f46fadd @defunctzombie update README
defunctzombie authored
51 Superagent is easily extended via plugins.
ca4ddc6 Clean up plugin section on the readme
Garrett Johnson authored
52
53 ```js
21216bc @montogeek Update Readme.md
montogeek authored
54 var nocache = require('superagent-no-cache');
ca4ddc6 Clean up plugin section on the readme
Garrett Johnson authored
55 var request = require('superagent');
56 var prefix = require('superagent-prefix')('/static');
57
58 request
59 .get('/some-url')
c279f59 @therebelrobot Fixed Prefix usage
therebelrobot authored
60 .use(prefix) // Prefixes *only* this request
ca4ddc6 Clean up plugin section on the readme
Garrett Johnson authored
61 .use(nocache) // Prevents caching of *only* this request
bf5a5d5 @ludovicofischer Correct broken Readme example.
ludovicofischer authored
62 .end(function(err, res){
ca4ddc6 Clean up plugin section on the readme
Garrett Johnson authored
63 // Do something
64 });
65 ```
66
67 Existing plugins:
68 * [superagent-no-cache](https://github.com/johntron/superagent-no-cache) - prevents caching by including Cache-Control header
69 * [superagent-prefix](https://github.com/johntron/superagent-prefix) - prefixes absolute URLs (useful in test environment)
7cdd2ba @oziks update existing plugins section of readme (adding superagent-mock)
oziks authored
70 * [superagent-mock](https://github.com/M6Web/superagent-mock) - simulate HTTP calls by returning data fixtures based on the requested URL
ca4ddc6 Clean up plugin section on the readme
Garrett Johnson authored
71
f46fadd @defunctzombie update README
defunctzombie authored
72 Please prefix your plugin with `superagent-*` so that it can easily be found by others.
ca4ddc6 Clean up plugin section on the readme
Garrett Johnson authored
73
74 For superagent extensions such as couchdb and oauth visit the [wiki](https://github.com/visionmedia/superagent/wiki).
75
8e52028 @tj make test docs
tj authored
76 ## Running node tests
77
f46fadd @defunctzombie update README
defunctzombie authored
78 Install dependencies:
49fc643 @hunterloftis updated readme with agent usage
hunterloftis authored
79
f46fadd @defunctzombie update README
defunctzombie authored
80 ```shell
81 $ npm install
82 ```
83 Run em!
49fc643 @hunterloftis updated readme with agent usage
hunterloftis authored
84
f46fadd @defunctzombie update README
defunctzombie authored
85 ```shell
86 $ make test
87 ```
8e52028 @tj make test docs
tj authored
88
89 ## Running browser tests
f808b57 @tj Initial commit
tj authored
90
f46fadd @defunctzombie update README
defunctzombie authored
91 Install dependencies:
f808b57 @tj Initial commit
tj authored
92
f46fadd @defunctzombie update README
defunctzombie authored
93 ```shell
94 $ npm install
95 ```
49fc643 @hunterloftis updated readme with agent usage
hunterloftis authored
96
f46fadd @defunctzombie update README
defunctzombie authored
97 Start the test runner:
3e57a54 @tj docs
tj authored
98
f46fadd @defunctzombie update README
defunctzombie authored
99 ```shell
100 $ make test-browser-local
101 ```
49fc643 @hunterloftis updated readme with agent usage
hunterloftis authored
102
f46fadd @defunctzombie update README
defunctzombie authored
103 Visit `http://localhost:4000/__zuul` in your browser.
49fc643 @hunterloftis updated readme with agent usage
hunterloftis authored
104
f46fadd @defunctzombie update README
defunctzombie authored
105 Edit tests and refresh your browser. You do not have to restart the test runner.
b3240d9 @tj wiki mention
tj authored
106
49fc643 @hunterloftis updated readme with agent usage
hunterloftis authored
107 ## License
f808b57 @tj Initial commit
tj authored
108
f46fadd @defunctzombie update README
defunctzombie authored
109 MIT
Something went wrong with that request. Please try again.