axios 0.19.0-beta.1 → 0.19.0
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 +35 -0
- package/README.md +23 -11
- package/dist/axios.js +9 -1
- package/dist/axios.map +1 -1
- package/dist/axios.min.js +2 -2
- package/dist/axios.min.map +1 -1
- package/index.d.ts +12 -10
- package/lib/adapters/http.js +3 -2
- package/lib/core/enhanceError.js +3 -0
- package/lib/helpers/buildURL.js +5 -0
- package/package.json +2 -2
package/index.d.ts
CHANGED
@@ -21,14 +21,14 @@ export interface AxiosProxyConfig {
|
|
21
21
|
protocol?: string;
|
22
22
|
}
|
23
23
|
|
24
|
-
export type Method =
|
25
|
-
| 'get'
|
26
|
-
| 'delete'
|
27
|
-
| 'head'
|
28
|
-
| 'options'
|
29
|
-
| 'post'
|
30
|
-
| 'put'
|
31
|
-
| 'patch'
|
24
|
+
export type Method =
|
25
|
+
| 'get' | 'GET'
|
26
|
+
| 'delete' | 'DELETE'
|
27
|
+
| 'head' | 'HEAD'
|
28
|
+
| 'options' | 'OPTIONS'
|
29
|
+
| 'post' | 'POST'
|
30
|
+
| 'put' | 'PUT'
|
31
|
+
| 'patch' | 'PATCH'
|
32
32
|
|
33
33
|
export type ResponseType =
|
34
34
|
| 'arraybuffer'
|
@@ -76,11 +76,12 @@ export interface AxiosResponse<T = any> {
|
|
76
76
|
request?: any;
|
77
77
|
}
|
78
78
|
|
79
|
-
export interface AxiosError extends Error {
|
79
|
+
export interface AxiosError<T = any> extends Error {
|
80
80
|
config: AxiosRequestConfig;
|
81
81
|
code?: string;
|
82
82
|
request?: any;
|
83
|
-
response?: AxiosResponse
|
83
|
+
response?: AxiosResponse<T>;
|
84
|
+
isAxiosError: boolean;
|
84
85
|
}
|
85
86
|
|
86
87
|
export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {
|
@@ -127,6 +128,7 @@ export interface AxiosInstance {
|
|
127
128
|
request: AxiosInterceptorManager<AxiosRequestConfig>;
|
128
129
|
response: AxiosInterceptorManager<AxiosResponse>;
|
129
130
|
};
|
131
|
+
getUri(config?: AxiosRequestConfig): string;
|
130
132
|
request<T = any, R = AxiosResponse<T>> (config: AxiosRequestConfig): Promise<R>;
|
131
133
|
get<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
132
134
|
delete<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
|
package/lib/adapters/http.js
CHANGED
@@ -83,7 +83,7 @@ module.exports = function httpAdapter(config) {
|
|
83
83
|
|
84
84
|
var options = {
|
85
85
|
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
|
86
|
-
method: config.method,
|
86
|
+
method: config.method.toUpperCase(),
|
87
87
|
headers: headers,
|
88
88
|
agent: agent,
|
89
89
|
auth: auth
|
@@ -188,7 +188,7 @@ module.exports = function httpAdapter(config) {
|
|
188
188
|
case 'compress':
|
189
189
|
case 'deflate':
|
190
190
|
// add the unzipper to the body stream processing pipeline
|
191
|
-
stream = stream.pipe(zlib.createUnzip());
|
191
|
+
stream = (res.statusCode === 204) ? stream : stream.pipe(zlib.createUnzip());
|
192
192
|
|
193
193
|
// remove the content-encoding in order to not confuse downstream operations
|
194
194
|
delete res.headers['content-encoding'];
|
@@ -216,6 +216,7 @@ module.exports = function httpAdapter(config) {
|
|
216
216
|
|
217
217
|
// make sure the content length is not over the maxContentLength if specified
|
218
218
|
if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
|
219
|
+
stream.destroy();
|
219
220
|
reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
220
221
|
config, null, lastRequest));
|
221
222
|
}
|
package/lib/core/enhanceError.js
CHANGED
@@ -15,8 +15,11 @@ module.exports = function enhanceError(error, config, code, request, response) {
|
|
15
15
|
if (code) {
|
16
16
|
error.code = code;
|
17
17
|
}
|
18
|
+
|
18
19
|
error.request = request;
|
19
20
|
error.response = response;
|
21
|
+
error.isAxiosError = true;
|
22
|
+
|
20
23
|
error.toJSON = function() {
|
21
24
|
return {
|
22
25
|
// Standard
|
package/lib/helpers/buildURL.js
CHANGED
@@ -59,6 +59,11 @@ module.exports = function buildURL(url, params, paramsSerializer) {
|
|
59
59
|
}
|
60
60
|
|
61
61
|
if (serializedParams) {
|
62
|
+
var hashmarkIndex = url.indexOf('#');
|
63
|
+
if (hashmarkIndex !== -1) {
|
64
|
+
url = url.slice(0, hashmarkIndex);
|
65
|
+
}
|
66
|
+
|
62
67
|
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
63
68
|
}
|
64
69
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "axios",
|
3
|
-
"version": "0.19.0
|
3
|
+
"version": "0.19.0",
|
4
4
|
"description": "Promise based HTTP client for the browser and node.js",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -73,7 +73,7 @@
|
|
73
73
|
},
|
74
74
|
"typings": "./index.d.ts",
|
75
75
|
"dependencies": {
|
76
|
-
"follow-redirects": "
|
76
|
+
"follow-redirects": "1.5.10",
|
77
77
|
"is-buffer": "^2.0.2"
|
78
78
|
},
|
79
79
|
"bundlesize": [
|