axios 0.5.0 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of axios might be problematic. Click here for more details.
- package/CHANGELOG.md +18 -1
- package/COOKBOOK.md +127 -0
- package/README.md +7 -2
- package/coverage/lcov-report/base.css +182 -0
- package/coverage/lcov-report/dist/axios.js.html +6075 -0
- package/coverage/lcov-report/dist/index.html +85 -0
- package/coverage/lcov-report/index.html +85 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +1 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +156 -0
- package/coverage/lcov-report/webpack.tests.js.html +10236 -0
- package/coverage/lcov.info +2366 -0
- package/dist/axios.amd.js +118 -116
- package/dist/axios.amd.map +1 -1
- package/dist/axios.amd.min.js +3 -3
- package/dist/axios.amd.min.map +1 -1
- package/dist/axios.amd.standalone.js +118 -116
- package/dist/axios.amd.standalone.map +1 -1
- package/dist/axios.amd.standalone.min.js +2 -2
- package/dist/axios.amd.standalone.min.map +1 -1
- package/dist/axios.js +118 -116
- package/dist/axios.map +1 -1
- package/dist/axios.min.js +3 -3
- package/dist/axios.min.map +1 -1
- package/dist/axios.standalone.js +118 -116
- package/dist/axios.standalone.map +1 -1
- package/dist/axios.standalone.min.js +2 -2
- package/dist/axios.standalone.min.map +1 -1
- package/examples/README.md +9 -0
- package/examples/all/index.html +44 -0
- package/examples/amd/index.html +37 -0
- package/examples/get/index.html +33 -0
- package/examples/get/people.json +26 -0
- package/examples/post/index.html +45 -0
- package/examples/server.js +98 -0
- package/examples/transform-response/index.html +44 -0
- package/examples/upload/index.html +43 -0
- package/examples/upload/server.js +11 -0
- package/lib/adapters/http.js +10 -7
- package/lib/adapters/xhr.js +23 -17
- package/lib/axios.js +36 -26
- package/lib/core/InterceptorManager.js +2 -3
- package/lib/core/dispatchRequest.js +0 -2
- package/lib/defaults.js +6 -5
- package/lib/helpers/cookies.js +1 -1
- package/lib/helpers/parseHeaders.js +2 -2
- package/lib/helpers/spread.js +3 -1
- package/lib/helpers/transformData.js +1 -1
- package/lib/helpers/urlIsSameOrigin.js +8 -6
- package/lib/utils.js +10 -6
- package/package.json +20 -12
- package/webpack.config.js +5 -10
- package/webpack.tests.js +2 -0
package/CHANGELOG.md
CHANGED
@@ -49,5 +49,22 @@
|
|
49
49
|
|
50
50
|
### 0.5.0 (Jan 23, 2015)
|
51
51
|
|
52
|
-
- Adding support for intercepetors
|
52
|
+
- Adding support for intercepetors ([#14](https://github.com/mzabriskie/axios/issues/14))
|
53
53
|
- Updating es6-promise dependency
|
54
|
+
|
55
|
+
### 0.5.1 (Mar 10, 2015)
|
56
|
+
|
57
|
+
- Fixing issue using strict mode ([#45](https://github.com/mzabriskie/axios/issues/45))
|
58
|
+
- Fixing issue with standalone build ([#47](https://github.com/mzabriskie/axios/issues/47))
|
59
|
+
|
60
|
+
### 0.5.2 (Mar 13, 2015)
|
61
|
+
|
62
|
+
- Adding support for `statusText` in response ([#46](https://github.com/mzabriskie/axios/issues/46))
|
63
|
+
|
64
|
+
### 0.5.3 (Apr 07, 2015)
|
65
|
+
|
66
|
+
- Using JSON.parse unconditionally when transforming response string ([#55](https://github.com/mzabriskie/axios/issues/55))
|
67
|
+
|
68
|
+
### 0.5.4 (Apr 08, 2015)
|
69
|
+
|
70
|
+
- Fixing issue with FormData not being sent ([#53](https://github.com/mzabriskie/axios/issues/53))
|
package/COOKBOOK.md
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# Cookbook
|
2
|
+
|
3
|
+
In an effort to keep axios as light weight as possible, and to avoid a rats nest of code for supporting every possible integration, it is often necessary to say no to feature requests. This doesn't mean that those use cases aren't legitimate, but rather that they are easily supported by augmenting axios with other libraries.
|
4
|
+
|
5
|
+
The following are the recipes for some of the commonly requested features.
|
6
|
+
|
7
|
+
### Promise.prototype.done
|
8
|
+
|
9
|
+
```bash
|
10
|
+
$ npm install axios promise --save
|
11
|
+
```
|
12
|
+
|
13
|
+
```js
|
14
|
+
var axios = require('axios');
|
15
|
+
require('promise/polyfill-done');
|
16
|
+
|
17
|
+
axios
|
18
|
+
.get('http://www.example.com/user')
|
19
|
+
.then(function (response) {
|
20
|
+
console.log(response.data);
|
21
|
+
return response;
|
22
|
+
})
|
23
|
+
.done();
|
24
|
+
```
|
25
|
+
|
26
|
+
### Promise.prototype.finally
|
27
|
+
|
28
|
+
```bash
|
29
|
+
$ npm install axios promise.prototype.finally --save
|
30
|
+
```
|
31
|
+
|
32
|
+
```js
|
33
|
+
var axios = require('axios');
|
34
|
+
require('promise.prototype.finally');
|
35
|
+
|
36
|
+
axios
|
37
|
+
.get('http://www.example.com/user')
|
38
|
+
.then(function (response) {
|
39
|
+
console.log(response.data);
|
40
|
+
return response;
|
41
|
+
})
|
42
|
+
.finally(function () {
|
43
|
+
console.log('this will always be called');
|
44
|
+
});
|
45
|
+
```
|
46
|
+
|
47
|
+
### Inflate/Deflate
|
48
|
+
|
49
|
+
```bash
|
50
|
+
$ npm install axios pako --save
|
51
|
+
```
|
52
|
+
|
53
|
+
```js
|
54
|
+
// client.js
|
55
|
+
var axios = require('axios');
|
56
|
+
var pako = require('pako');
|
57
|
+
|
58
|
+
var user = {
|
59
|
+
firstName: 'Fred',
|
60
|
+
lastName: 'Flintstone'
|
61
|
+
};
|
62
|
+
|
63
|
+
var data = pako.deflate(JSON.stringify(user), { to: 'string' });
|
64
|
+
|
65
|
+
axios
|
66
|
+
.post('http://127.0.0.1:3333/user', data)
|
67
|
+
.then(function (response) {
|
68
|
+
response.data = JSON.parse(pako.inflate(response.data, { to: 'string' }));
|
69
|
+
console.log(response.data);
|
70
|
+
return response;
|
71
|
+
});
|
72
|
+
```
|
73
|
+
|
74
|
+
```js
|
75
|
+
// server.js
|
76
|
+
var pako = require('pako');
|
77
|
+
var http = require('http');
|
78
|
+
var url = require('url');
|
79
|
+
var server;
|
80
|
+
|
81
|
+
server = http.createServer(function (req, res) {
|
82
|
+
req.setEncoding('utf8');
|
83
|
+
|
84
|
+
var parsed = url.parse(req.url, true);
|
85
|
+
var pathname = parsed.pathname;
|
86
|
+
|
87
|
+
if (pathname === '/user') {
|
88
|
+
var data = '';
|
89
|
+
req.on('data', function (chunk) {
|
90
|
+
data += chunk;
|
91
|
+
});
|
92
|
+
|
93
|
+
req.on('end', function () {
|
94
|
+
var user = JSON.parse(pako.inflate(data, { to: 'string' }));
|
95
|
+
console.log(user);
|
96
|
+
|
97
|
+
res.writeHead(200, {
|
98
|
+
'Content-Type': 'application/json'
|
99
|
+
});
|
100
|
+
res.end(pako.deflate(JSON.stringify({result: 'success'}), { to: 'string' }));
|
101
|
+
});
|
102
|
+
} else {
|
103
|
+
res.writeHead(404);
|
104
|
+
res.end(pako.deflate(JSON.stringify({result: 'error'}), { to: 'string' }));
|
105
|
+
}
|
106
|
+
});
|
107
|
+
|
108
|
+
server.listen(3333);
|
109
|
+
```
|
110
|
+
|
111
|
+
### JSONP
|
112
|
+
|
113
|
+
```bash
|
114
|
+
$ npm install jsonp --save
|
115
|
+
```
|
116
|
+
|
117
|
+
```js
|
118
|
+
var jsonp = require('jsonp');
|
119
|
+
|
120
|
+
jsonp('http://www.example.com/foo', null, function (err, data) {
|
121
|
+
if (err) {
|
122
|
+
console.error(error.message);
|
123
|
+
} else {
|
124
|
+
console.log(data);
|
125
|
+
}
|
126
|
+
});
|
127
|
+
```
|
package/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
#axios
|
1
|
+
# axios
|
2
2
|
|
3
3
|
[](https://www.npmjs.org/package/axios)
|
4
|
-
[](https://www.npmjs.org/package/axios)
|
5
4
|
[](https://travis-ci.org/mzabriskie/axios)
|
5
|
+
[](https://coveralls.io/r/mzabriskie/axios)
|
6
|
+
[](https://www.npmjs.org/package/axios)
|
6
7
|
[](https://david-dm.org/mzabriskie/axios)
|
7
8
|
|
8
9
|
Promise based HTTP client for the browser and node.js
|
@@ -200,6 +201,9 @@ The response for a request contains the following information.
|
|
200
201
|
|
201
202
|
// `status` is the HTTP status code from the server response
|
202
203
|
status: 200,
|
204
|
+
|
205
|
+
// `statusText` is the HTTP status message from the server response
|
206
|
+
statusText: 'OK',
|
203
207
|
|
204
208
|
// `headers` the headers that the server responded with
|
205
209
|
headers: {},
|
@@ -216,6 +220,7 @@ axios.get('/user/12345')
|
|
216
220
|
.then(function(response) {
|
217
221
|
console.log(response.data);
|
218
222
|
console.log(response.status);
|
223
|
+
console.log(response.statusText);
|
219
224
|
console.log(response.headers);
|
220
225
|
console.log(response.config);
|
221
226
|
});
|
@@ -0,0 +1,182 @@
|
|
1
|
+
body, html {
|
2
|
+
margin:0; padding: 0;
|
3
|
+
}
|
4
|
+
body {
|
5
|
+
font-family: Helvetica Neue, Helvetica,Arial;
|
6
|
+
font-size: 10pt;
|
7
|
+
}
|
8
|
+
div.header, div.footer {
|
9
|
+
background: #eee;
|
10
|
+
padding: 1em;
|
11
|
+
}
|
12
|
+
div.header {
|
13
|
+
z-index: 100;
|
14
|
+
position: fixed;
|
15
|
+
top: 0;
|
16
|
+
border-bottom: 1px solid #666;
|
17
|
+
width: 100%;
|
18
|
+
}
|
19
|
+
div.footer {
|
20
|
+
border-top: 1px solid #666;
|
21
|
+
}
|
22
|
+
div.body {
|
23
|
+
margin-top: 10em;
|
24
|
+
}
|
25
|
+
div.meta {
|
26
|
+
font-size: 90%;
|
27
|
+
text-align: center;
|
28
|
+
}
|
29
|
+
h1, h2, h3 {
|
30
|
+
font-weight: normal;
|
31
|
+
}
|
32
|
+
h1 {
|
33
|
+
font-size: 12pt;
|
34
|
+
}
|
35
|
+
h2 {
|
36
|
+
font-size: 10pt;
|
37
|
+
}
|
38
|
+
pre {
|
39
|
+
font-family: Consolas, Menlo, Monaco, monospace;
|
40
|
+
margin: 0;
|
41
|
+
padding: 0;
|
42
|
+
line-height: 14px;
|
43
|
+
font-size: 14px;
|
44
|
+
-moz-tab-size: 2;
|
45
|
+
-o-tab-size: 2;
|
46
|
+
tab-size: 2;
|
47
|
+
}
|
48
|
+
|
49
|
+
div.path { font-size: 110%; }
|
50
|
+
div.path a:link, div.path a:visited { color: #000; }
|
51
|
+
table.coverage { border-collapse: collapse; margin:0; padding: 0 }
|
52
|
+
|
53
|
+
table.coverage td {
|
54
|
+
margin: 0;
|
55
|
+
padding: 0;
|
56
|
+
color: #111;
|
57
|
+
vertical-align: top;
|
58
|
+
}
|
59
|
+
table.coverage td.line-count {
|
60
|
+
width: 50px;
|
61
|
+
text-align: right;
|
62
|
+
padding-right: 5px;
|
63
|
+
}
|
64
|
+
table.coverage td.line-coverage {
|
65
|
+
color: #777 !important;
|
66
|
+
text-align: right;
|
67
|
+
border-left: 1px solid #666;
|
68
|
+
border-right: 1px solid #666;
|
69
|
+
}
|
70
|
+
|
71
|
+
table.coverage td.text {
|
72
|
+
}
|
73
|
+
|
74
|
+
table.coverage td span.cline-any {
|
75
|
+
display: inline-block;
|
76
|
+
padding: 0 5px;
|
77
|
+
width: 40px;
|
78
|
+
}
|
79
|
+
table.coverage td span.cline-neutral {
|
80
|
+
background: #eee;
|
81
|
+
}
|
82
|
+
table.coverage td span.cline-yes {
|
83
|
+
background: #b5d592;
|
84
|
+
color: #999;
|
85
|
+
}
|
86
|
+
table.coverage td span.cline-no {
|
87
|
+
background: #fc8c84;
|
88
|
+
}
|
89
|
+
|
90
|
+
.cstat-yes { color: #111; }
|
91
|
+
.cstat-no { background: #fc8c84; color: #111; }
|
92
|
+
.fstat-no { background: #ffc520; color: #111 !important; }
|
93
|
+
.cbranch-no { background: yellow !important; color: #111; }
|
94
|
+
|
95
|
+
.cstat-skip { background: #ddd; color: #111; }
|
96
|
+
.fstat-skip { background: #ddd; color: #111 !important; }
|
97
|
+
.cbranch-skip { background: #ddd !important; color: #111; }
|
98
|
+
|
99
|
+
.missing-if-branch {
|
100
|
+
display: inline-block;
|
101
|
+
margin-right: 10px;
|
102
|
+
position: relative;
|
103
|
+
padding: 0 4px;
|
104
|
+
background: black;
|
105
|
+
color: yellow;
|
106
|
+
}
|
107
|
+
|
108
|
+
.skip-if-branch {
|
109
|
+
display: none;
|
110
|
+
margin-right: 10px;
|
111
|
+
position: relative;
|
112
|
+
padding: 0 4px;
|
113
|
+
background: #ccc;
|
114
|
+
color: white;
|
115
|
+
}
|
116
|
+
|
117
|
+
.missing-if-branch .typ, .skip-if-branch .typ {
|
118
|
+
color: inherit !important;
|
119
|
+
}
|
120
|
+
|
121
|
+
.entity, .metric { font-weight: bold; }
|
122
|
+
.metric { display: inline-block; border: 1px solid #333; padding: 0.3em; background: white; }
|
123
|
+
.metric small { font-size: 80%; font-weight: normal; color: #666; }
|
124
|
+
|
125
|
+
div.coverage-summary table { border-collapse: collapse; margin: 3em; font-size: 110%; }
|
126
|
+
div.coverage-summary td, div.coverage-summary table th { margin: 0; padding: 0.25em 1em; border-top: 1px solid #666; border-bottom: 1px solid #666; }
|
127
|
+
div.coverage-summary th { text-align: left; border: 1px solid #666; background: #eee; font-weight: normal; }
|
128
|
+
div.coverage-summary th.file { border-right: none !important; }
|
129
|
+
div.coverage-summary th.pic { border-left: none !important; text-align: right; }
|
130
|
+
div.coverage-summary th.pct { border-right: none !important; }
|
131
|
+
div.coverage-summary th.abs { border-left: none !important; text-align: right; }
|
132
|
+
div.coverage-summary td.pct { text-align: right; border-left: 1px solid #666; }
|
133
|
+
div.coverage-summary td.abs { text-align: right; font-size: 90%; color: #444; border-right: 1px solid #666; }
|
134
|
+
div.coverage-summary td.file { text-align: right; border-left: 1px solid #666; white-space: nowrap; }
|
135
|
+
div.coverage-summary td.pic { min-width: 120px !important; }
|
136
|
+
div.coverage-summary a:link { text-decoration: none; color: #000; }
|
137
|
+
div.coverage-summary a:visited { text-decoration: none; color: #333; }
|
138
|
+
div.coverage-summary a:hover { text-decoration: underline; }
|
139
|
+
div.coverage-summary tfoot td { border-top: 1px solid #666; }
|
140
|
+
|
141
|
+
div.coverage-summary .sorter {
|
142
|
+
height: 10px;
|
143
|
+
width: 7px;
|
144
|
+
display: inline-block;
|
145
|
+
margin-left: 0.5em;
|
146
|
+
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
147
|
+
}
|
148
|
+
div.coverage-summary .sorted .sorter {
|
149
|
+
background-position: 0 -20px;
|
150
|
+
}
|
151
|
+
div.coverage-summary .sorted-desc .sorter {
|
152
|
+
background-position: 0 -10px;
|
153
|
+
}
|
154
|
+
|
155
|
+
.high { background: #b5d592 !important; }
|
156
|
+
.medium { background: #ffe87c !important; }
|
157
|
+
.low { background: #fc8c84 !important; }
|
158
|
+
|
159
|
+
span.cover-fill, span.cover-empty {
|
160
|
+
display:inline-block;
|
161
|
+
border:1px solid #444;
|
162
|
+
background: white;
|
163
|
+
height: 12px;
|
164
|
+
}
|
165
|
+
span.cover-fill {
|
166
|
+
background: #ccc;
|
167
|
+
border-right: 1px solid #444;
|
168
|
+
}
|
169
|
+
span.cover-empty {
|
170
|
+
background: white;
|
171
|
+
border-left: none;
|
172
|
+
}
|
173
|
+
span.cover-full {
|
174
|
+
border-right: none !important;
|
175
|
+
}
|
176
|
+
pre.prettyprint {
|
177
|
+
border: none !important;
|
178
|
+
padding: 0 !important;
|
179
|
+
margin: 0 !important;
|
180
|
+
}
|
181
|
+
.com { color: #999 !important; }
|
182
|
+
.ignore-none { color: #999; font-weight: normal; }
|