mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +03:00
Merge branch 'master' into bugfix/allow-method-in-instance-config
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
<!-- Click "Preview" for a more readable version -->
|
<!-- Click "Preview" for a more readable version -->
|
||||||
|
|
||||||
#### Instructions
|
#### Instructions
|
||||||
|
|
||||||
Please read and follow this instructions before submitting an issue:
|
Please read and follow the instructions before submitting an issue:
|
||||||
|
|
||||||
- Read all our documentation, specially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
|
- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
|
||||||
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
|
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
|
||||||
- If you aren't sure that the issue is caused by axios or you just need for help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
|
- If you aren't sure that the issue is caused by axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
|
||||||
- If you're reporting a bug, ensure it isn't already fixed in the latest axios version.
|
- If you're reporting a bug, ensure it isn't already fixed in the latest axios version.
|
||||||
- If you need a new feature there's a chance it's already implemented in a [library](https://github.com/axios/axios/blob/master/ECOSYSTEM.md) or you can implement it using [interceptors](https://github.com/axios/axios#interceptors).
|
- If you need a new feature there's a chance it's already implemented in a [library](https://github.com/axios/axios/blob/master/ECOSYSTEM.md) or you can implement it using [interceptors](https://github.com/axios/axios#interceptors).
|
||||||
|
|
||||||
*^^^ Delete the instructions before submitting the issue ^^^*
|
**⚠️👆 Delete the instructions before submitting the issue 👆⚠️**
|
||||||
|
|
||||||
#### Summary
|
#### Summary
|
||||||
|
|
||||||
Describe your issue here, including as much detail as necessary.
|
Describe your issue here, including as much detail as necessary.
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ If you're reporting a bug, include the relevant code and stack traces to debug i
|
|||||||
|
|
||||||
If you're requesting a feature, include some context and examples of code using it.
|
If you're requesting a feature, include some context and examples of code using it.
|
||||||
|
|
||||||
#### Context
|
#### Context
|
||||||
|
|
||||||
- axios version: *e.g.: v0.16.0*
|
- axios version: *e.g.: v0.16.0*
|
||||||
- Environment: *e.g.: node v6.9.4, chrome 54, windows 7*
|
- Environment: *e.g.: node v6.9.4, chrome 54, windows 7*
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<!-- Click "Preview" for a more readable version -->
|
<!-- Click "Preview" for a more readable version -->
|
||||||
|
|
||||||
#### Instructions
|
#### Instructions
|
||||||
|
|
||||||
Please read and follow this instructions before creating and submitting a pull request:
|
Please read and follow the instructions before creating and submitting a pull request:
|
||||||
|
|
||||||
- Create an issue explaining the feature. It could save you some effort in case we don't consider it should be included in axios.
|
- Create an issue explaining the feature. It could save you some effort in case we don't consider it should be included in axios.
|
||||||
- If you're fixing a bug, try to commit the failing test/s and the code fixing it in different commits.
|
- If you're fixing a bug, try to commit the failing test/s and the code fixing it in different commits.
|
||||||
- Ensure you're following our [contributing guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md).
|
- Ensure you're following our [contributing guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md).
|
||||||
|
|
||||||
*^^^ Delete the instructions before submitting the pull request ^^^*
|
**⚠️👆 Delete the instructions before submitting the pull request 👆⚠️**
|
||||||
|
|
||||||
Describe your pull request here.
|
Describe your pull request here.
|
||||||
|
|||||||
@@ -1,5 +1,29 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
### 0.18.0 (Feb 19, 2018)
|
||||||
|
|
||||||
|
- Adding support for UNIX Sockets when running with Node.js ([#1070](https://github.com/axios/axios/pull/1070))
|
||||||
|
- Fixing typings ([#1177](https://github.com/axios/axios/pull/1177)):
|
||||||
|
- AxiosRequestConfig.proxy: allows type false
|
||||||
|
- AxiosProxyConfig: added auth field
|
||||||
|
- Adding function signature in AxiosInstance interface so AxiosInstance can be invoked ([#1192](https://github.com/axios/axios/pull/1192), [#1254](https://github.com/axios/axios/pull/1254))
|
||||||
|
- Allowing maxContentLength to pass through to redirected calls as maxBodyLength in follow-redirects config ([#1287](https://github.com/axios/axios/pull/1287))
|
||||||
|
- Fixing configuration when using an instance - method can now be set ([#1342](https://github.com/axios/axios/pull/1342))
|
||||||
|
|
||||||
|
|
||||||
|
### 0.17.1 (Nov 11, 2017)
|
||||||
|
|
||||||
|
- Fixing issue with web workers ([#1160](https://github.com/axios/axios/pull/1160))
|
||||||
|
- Allowing overriding transport ([#1080](https://github.com/axios/axios/pull/1080))
|
||||||
|
- Updating TypeScript typings ([#1165](https://github.com/axios/axios/pull/1165), [#1125](https://github.com/axios/axios/pull/1125), [#1131](https://github.com/axios/axios/pull/1131))
|
||||||
|
|
||||||
|
### 0.17.0 (Oct 21, 2017)
|
||||||
|
|
||||||
|
- **BREAKING** Fixing issue with `baseURL` and interceptors ([#950](https://github.com/axios/axios/pull/950))
|
||||||
|
- **BREAKING** Improving handing of duplicate headers ([#874](https://github.com/axios/axios/pull/874))
|
||||||
|
- Adding support for disabling proxies ([#691](https://github.com/axios/axios/pull/691))
|
||||||
|
- Updating TypeScript typings with generic type parameters ([#1061](https://github.com/axios/axios/pull/1061))
|
||||||
|
|
||||||
### 0.16.2 (Jun 3, 2017)
|
### 0.16.2 (Jun 3, 2017)
|
||||||
|
|
||||||
- Fixing issue with including `buffer` in bundle ([#887](https://github.com/axios/axios/pull/887))
|
- Fixing issue with including `buffer` in bundle ([#887](https://github.com/axios/axios/pull/887))
|
||||||
|
|||||||
@@ -15,3 +15,6 @@ This is a list of axios related libraries and resources. If you have a suggestio
|
|||||||
* [mocha-axios](https://github.com/jdrydn/mocha-axios) - Streamlined integration testing with Mocha & Axios
|
* [mocha-axios](https://github.com/jdrydn/mocha-axios) - Streamlined integration testing with Mocha & Axios
|
||||||
* [axiosist](https://github.com/Gerhut/axiosist) - Axios based supertest: convert node.js request handler to axios adapter, used for node.js server unit test.
|
* [axiosist](https://github.com/Gerhut/axiosist) - Axios based supertest: convert node.js request handler to axios adapter, used for node.js server unit test.
|
||||||
* [axios-cache-plugin](https://github.com/jin5354/axios-cache-plugin) - Help you cache GET request when using axios.
|
* [axios-cache-plugin](https://github.com/jin5354/axios-cache-plugin) - Help you cache GET request when using axios.
|
||||||
|
* [axios-extensions](https://github.com/kuitos/axios-extensions) - A collection of axios extensions, including throttle and cache GET request plugin.
|
||||||
|
* [redux-saga-requests](https://github.com/klis87/redux-saga-requests) - Redux-Saga addon to simplify handling of AJAX requests.
|
||||||
|
* [axios-fetch](https://github.com/lifeomic/axios-fetch) - A WebAPI Fetch implementation backed by an Axios client
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2014 Matt Zabriskie
|
Copyright (c) 2014-present Matt Zabriskie
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
# axios
|
# axios
|
||||||
|
|
||||||
[](https://www.npmjs.org/package/axios)
|
[](https://www.npmjs.org/package/axios)
|
||||||
[](https://travis-ci.org/mzabriskie/axios)
|
[](https://travis-ci.org/axios/axios)
|
||||||
[](https://coveralls.io/r/mzabriskie/axios)
|
[](https://coveralls.io/r/mzabriskie/axios)
|
||||||
[](http://npm-stat.com/charts.html?package=axios)
|
[](http://npm-stat.com/charts.html?package=axios)
|
||||||
[](https://gitter.im/mzabriskie/axios)
|
[](https://gitter.im/mzabriskie/axios)
|
||||||
|
[](https://www.codetriage.com/axios/axios)
|
||||||
|
|
||||||
Promise based HTTP client for the browser and node.js
|
Promise based HTTP client for the browser and node.js
|
||||||
|
|
||||||
@@ -312,6 +313,12 @@ These are the available config options for making requests. Only the `url` is re
|
|||||||
// If set to 0, no redirects will be followed.
|
// If set to 0, no redirects will be followed.
|
||||||
maxRedirects: 5, // default
|
maxRedirects: 5, // default
|
||||||
|
|
||||||
|
// `socketPath` defines a UNIX Socket to be used in node.js.
|
||||||
|
// e.g. '/var/run/docker.sock' to send requests to the docker daemon.
|
||||||
|
// Only either `socketPath` or `proxy` can be specified.
|
||||||
|
// If both are specified, `socketPath` is used.
|
||||||
|
socketPath: null, // default
|
||||||
|
|
||||||
// `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
|
// `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
|
||||||
// and https requests, respectively, in node.js. This allows options to be added like
|
// and https requests, respectively, in node.js. This allows options to be added like
|
||||||
// `keepAlive` that are not enabled by default.
|
// `keepAlive` that are not enabled by default.
|
||||||
@@ -410,7 +417,7 @@ instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;
|
|||||||
|
|
||||||
### Config order of precedence
|
### Config order of precedence
|
||||||
|
|
||||||
Config will be merged with an order of precedence. The order is library defaults found in `lib/defaults.js`, then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example.
|
Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Create an instance using the config defaults provided by the library
|
// Create an instance using the config defaults provided by the library
|
||||||
@@ -521,6 +528,12 @@ axios.get('/user/12345', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
axios.post('/user/12345', {
|
||||||
|
name: 'new name'
|
||||||
|
}, {
|
||||||
|
cancelToken: source.token
|
||||||
|
})
|
||||||
|
|
||||||
// cancel the request (the message parameter is optional)
|
// cancel the request (the message parameter is optional)
|
||||||
source.cancel('Operation canceled by the user.');
|
source.cancel('Operation canceled by the user.');
|
||||||
```
|
```
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "axios",
|
"name": "axios",
|
||||||
"main": "./dist/axios.js",
|
"main": "./dist/axios.js",
|
||||||
"version": "0.16.2",
|
"version": "0.18.0",
|
||||||
"homepage": "https://github.com/axios/axios",
|
"homepage": "https://github.com/axios/axios",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Matt Zabriskie"
|
"Matt Zabriskie"
|
||||||
|
|||||||
Vendored
+86
-68
@@ -1,4 +1,4 @@
|
|||||||
/* axios v0.16.2 | (c) 2017 by Matt Zabriskie */
|
/* axios v0.18.0 | (c) 2018 by Matt Zabriskie */
|
||||||
(function webpackUniversalModuleDefinition(root, factory) {
|
(function webpackUniversalModuleDefinition(root, factory) {
|
||||||
if(typeof exports === 'object' && typeof module === 'object')
|
if(typeof exports === 'object' && typeof module === 'object')
|
||||||
module.exports = factory();
|
module.exports = factory();
|
||||||
@@ -53,13 +53,13 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/******/ ([
|
/******/ ([
|
||||||
/* 0 */
|
/* 0 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
module.exports = __webpack_require__(1);
|
module.exports = __webpack_require__(1);
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 1 */
|
/* 1 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -115,9 +115,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
module.exports.default = axios;
|
module.exports.default = axios;
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 2 */
|
/* 2 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -328,7 +328,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Force an array if not already something iterable
|
// Force an array if not already something iterable
|
||||||
if (typeof obj !== 'object' && !isArray(obj)) {
|
if (typeof obj !== 'object') {
|
||||||
/*eslint no-param-reassign:0*/
|
/*eslint no-param-reassign:0*/
|
||||||
obj = [obj];
|
obj = [obj];
|
||||||
}
|
}
|
||||||
@@ -424,9 +424,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 3 */
|
/* 3 */
|
||||||
/***/ function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -441,14 +441,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 4 */
|
/* 4 */
|
||||||
/***/ function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Determine if an object is a Buffer
|
* Determine if an object is a Buffer
|
||||||
*
|
*
|
||||||
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
* @author Feross Aboukhadijeh <https://feross.org>
|
||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -468,9 +468,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 5 */
|
/* 5 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -478,8 +478,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
var utils = __webpack_require__(2);
|
var utils = __webpack_require__(2);
|
||||||
var InterceptorManager = __webpack_require__(17);
|
var InterceptorManager = __webpack_require__(17);
|
||||||
var dispatchRequest = __webpack_require__(18);
|
var dispatchRequest = __webpack_require__(18);
|
||||||
var isAbsoluteURL = __webpack_require__(21);
|
|
||||||
var combineURLs = __webpack_require__(22);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of Axios
|
* Create a new instance of Axios
|
||||||
@@ -508,14 +506,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
}, arguments[1]);
|
}, arguments[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
|
config = utils.merge(defaults, {method: 'get'}, this.defaults, config);
|
||||||
config.method = config.method.toLowerCase();
|
config.method = config.method.toLowerCase();
|
||||||
|
|
||||||
// Support baseURL config
|
|
||||||
if (config.baseURL && !isAbsoluteURL(config.url)) {
|
|
||||||
config.url = combineURLs(config.baseURL, config.url);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hook up interceptors middleware
|
// Hook up interceptors middleware
|
||||||
var chain = [dispatchRequest, undefined];
|
var chain = [dispatchRequest, undefined];
|
||||||
var promise = Promise.resolve(config);
|
var promise = Promise.resolve(config);
|
||||||
@@ -560,9 +553,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
module.exports = Axios;
|
module.exports = Axios;
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 6 */
|
/* 6 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -629,6 +622,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
return data;
|
return data;
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
||||||
|
* timeout is not created.
|
||||||
|
*/
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
|
|
||||||
xsrfCookieName: 'XSRF-TOKEN',
|
xsrfCookieName: 'XSRF-TOKEN',
|
||||||
@@ -658,9 +655,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
module.exports = defaults;
|
module.exports = defaults;
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 7 */
|
/* 7 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -676,9 +673,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 8 */
|
/* 8 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -748,7 +745,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
|
var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
|
||||||
var response = {
|
var response = {
|
||||||
data: responseData,
|
data: responseData,
|
||||||
// IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)
|
// IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201)
|
||||||
status: request.status === 1223 ? 204 : request.status,
|
status: request.status === 1223 ? 204 : request.status,
|
||||||
statusText: request.status === 1223 ? 'No Content' : request.statusText,
|
statusText: request.status === 1223 ? 'No Content' : request.statusText,
|
||||||
headers: responseHeaders,
|
headers: responseHeaders,
|
||||||
@@ -862,9 +859,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 9 */
|
/* 9 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -894,9 +891,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 10 */
|
/* 10 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -918,9 +915,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 11 */
|
/* 11 */
|
||||||
/***/ function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -945,9 +942,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 12 */
|
/* 12 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -992,9 +989,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
|
|
||||||
if (utils.isArray(val)) {
|
if (utils.isArray(val)) {
|
||||||
key = key + '[]';
|
key = key + '[]';
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (!utils.isArray(val)) {
|
|
||||||
val = [val];
|
val = [val];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1019,14 +1014,23 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 13 */
|
/* 13 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var utils = __webpack_require__(2);
|
var utils = __webpack_require__(2);
|
||||||
|
|
||||||
|
// Headers whose duplicates are ignored by node
|
||||||
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
||||||
|
var ignoreDuplicateOf = [
|
||||||
|
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
||||||
|
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
||||||
|
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
||||||
|
'referer', 'retry-after', 'user-agent'
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse headers into an object
|
* Parse headers into an object
|
||||||
*
|
*
|
||||||
@@ -1054,7 +1058,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
val = utils.trim(line.substr(i + 1));
|
val = utils.trim(line.substr(i + 1));
|
||||||
|
|
||||||
if (key) {
|
if (key) {
|
||||||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (key === 'set-cookie') {
|
||||||
|
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
|
||||||
|
} else {
|
||||||
|
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1062,9 +1073,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 14 */
|
/* 14 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -1136,9 +1147,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 15 */
|
/* 15 */
|
||||||
/***/ function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -1178,9 +1189,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
module.exports = btoa;
|
module.exports = btoa;
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 16 */
|
/* 16 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -1237,9 +1248,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 17 */
|
/* 17 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -1295,9 +1306,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
module.exports = InterceptorManager;
|
module.exports = InterceptorManager;
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 18 */
|
/* 18 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -1305,6 +1316,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
var transformData = __webpack_require__(19);
|
var transformData = __webpack_require__(19);
|
||||||
var isCancel = __webpack_require__(20);
|
var isCancel = __webpack_require__(20);
|
||||||
var defaults = __webpack_require__(6);
|
var defaults = __webpack_require__(6);
|
||||||
|
var isAbsoluteURL = __webpack_require__(21);
|
||||||
|
var combineURLs = __webpack_require__(22);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws a `Cancel` if cancellation has been requested.
|
* Throws a `Cancel` if cancellation has been requested.
|
||||||
@@ -1324,6 +1337,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
module.exports = function dispatchRequest(config) {
|
module.exports = function dispatchRequest(config) {
|
||||||
throwIfCancellationRequested(config);
|
throwIfCancellationRequested(config);
|
||||||
|
|
||||||
|
// Support baseURL config
|
||||||
|
if (config.baseURL && !isAbsoluteURL(config.url)) {
|
||||||
|
config.url = combineURLs(config.baseURL, config.url);
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure headers exist
|
// Ensure headers exist
|
||||||
config.headers = config.headers || {};
|
config.headers = config.headers || {};
|
||||||
|
|
||||||
@@ -1380,9 +1398,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 19 */
|
/* 19 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -1406,9 +1424,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 20 */
|
/* 20 */
|
||||||
/***/ function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -1417,9 +1435,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 21 */
|
/* 21 */
|
||||||
/***/ function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -1437,9 +1455,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 22 */
|
/* 22 */
|
||||||
/***/ function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -1457,9 +1475,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 23 */
|
/* 23 */
|
||||||
/***/ function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -1482,9 +1500,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
module.exports = Cancel;
|
module.exports = Cancel;
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 24 */
|
/* 24 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -1545,9 +1563,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
module.exports = CancelToken;
|
module.exports = CancelToken;
|
||||||
|
|
||||||
|
|
||||||
/***/ },
|
/***/ }),
|
||||||
/* 25 */
|
/* 25 */
|
||||||
/***/ function(module, exports) {
|
/***/ (function(module, exports) {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -1578,7 +1596,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ }
|
/***/ })
|
||||||
/******/ ])
|
/******/ ])
|
||||||
});
|
});
|
||||||
;
|
;
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+4
-4
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+19
-14
@@ -1,9 +1,9 @@
|
|||||||
export interface AxiosTransformer {
|
export interface AxiosTransformer {
|
||||||
(data: any): any;
|
(data: any, headers?: any): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosAdapter {
|
export interface AxiosAdapter {
|
||||||
(config: AxiosRequestConfig): AxiosPromise;
|
(config: AxiosRequestConfig): AxiosPromise<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosBasicCredentials {
|
export interface AxiosBasicCredentials {
|
||||||
@@ -14,6 +14,10 @@ export interface AxiosBasicCredentials {
|
|||||||
export interface AxiosProxyConfig {
|
export interface AxiosProxyConfig {
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
|
auth?: {
|
||||||
|
username: string;
|
||||||
|
password:string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosRequestConfig {
|
export interface AxiosRequestConfig {
|
||||||
@@ -40,16 +44,17 @@ export interface AxiosRequestConfig {
|
|||||||
maxRedirects?: number;
|
maxRedirects?: number;
|
||||||
httpAgent?: any;
|
httpAgent?: any;
|
||||||
httpsAgent?: any;
|
httpsAgent?: any;
|
||||||
proxy?: AxiosProxyConfig;
|
proxy?: AxiosProxyConfig | false;
|
||||||
cancelToken?: CancelToken;
|
cancelToken?: CancelToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosResponse {
|
export interface AxiosResponse<T = any> {
|
||||||
data: any;
|
data: T;
|
||||||
status: number;
|
status: number;
|
||||||
statusText: string;
|
statusText: string;
|
||||||
headers: any;
|
headers: any;
|
||||||
config: AxiosRequestConfig;
|
config: AxiosRequestConfig;
|
||||||
|
request?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosError extends Error {
|
export interface AxiosError extends Error {
|
||||||
@@ -59,7 +64,7 @@ export interface AxiosError extends Error {
|
|||||||
response?: AxiosResponse;
|
response?: AxiosResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosPromise extends Promise<AxiosResponse> {
|
export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CancelStatic {
|
export interface CancelStatic {
|
||||||
@@ -91,28 +96,28 @@ export interface CancelTokenSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosInterceptorManager<V> {
|
export interface AxiosInterceptorManager<V> {
|
||||||
use(onFulfilled: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
|
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
|
||||||
eject(id: number): void;
|
eject(id: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosInstance {
|
export interface AxiosInstance {
|
||||||
|
(config: AxiosRequestConfig): AxiosPromise;
|
||||||
|
(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
||||||
defaults: AxiosRequestConfig;
|
defaults: AxiosRequestConfig;
|
||||||
interceptors: {
|
interceptors: {
|
||||||
request: AxiosInterceptorManager<AxiosRequestConfig>;
|
request: AxiosInterceptorManager<AxiosRequestConfig>;
|
||||||
response: AxiosInterceptorManager<AxiosResponse>;
|
response: AxiosInterceptorManager<AxiosResponse>;
|
||||||
};
|
};
|
||||||
request(config: AxiosRequestConfig): AxiosPromise;
|
request<T = any>(config: AxiosRequestConfig): AxiosPromise<T>;
|
||||||
get(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
get<T = any>(url: string, config?: AxiosRequestConfig): AxiosPromise<T>;
|
||||||
delete(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
delete(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
||||||
head(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
head(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
||||||
post(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise;
|
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>;
|
||||||
put(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise;
|
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>;
|
||||||
patch(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise;
|
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosStatic extends AxiosInstance {
|
export interface AxiosStatic extends AxiosInstance {
|
||||||
(config: AxiosRequestConfig): AxiosPromise;
|
|
||||||
(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
|
||||||
create(config?: AxiosRequestConfig): AxiosInstance;
|
create(config?: AxiosRequestConfig): AxiosInstance;
|
||||||
Cancel: CancelStatic;
|
Cancel: CancelStatic;
|
||||||
CancelToken: CancelTokenStatic;
|
CancelToken: CancelTokenStatic;
|
||||||
|
|||||||
+1
-1
@@ -221,7 +221,7 @@ module.exports = function(config) {
|
|||||||
sauceLabs: {
|
sauceLabs: {
|
||||||
recordScreenshots: false,
|
recordScreenshots: false,
|
||||||
connectOptions: {
|
connectOptions: {
|
||||||
port: 5757,
|
// port: 5757,
|
||||||
logfile: 'sauce_connect.log'
|
logfile: 'sauce_connect.log'
|
||||||
},
|
},
|
||||||
public: 'public'
|
public: 'public'
|
||||||
|
|||||||
Regular → Executable
+14
-3
@@ -72,8 +72,6 @@ module.exports = function httpAdapter(config) {
|
|||||||
var agent = isHttps ? config.httpsAgent : config.httpAgent;
|
var agent = isHttps ? config.httpsAgent : config.httpAgent;
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
hostname: parsed.hostname,
|
|
||||||
port: parsed.port,
|
|
||||||
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
|
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
|
||||||
method: config.method,
|
method: config.method,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
@@ -81,6 +79,13 @@ module.exports = function httpAdapter(config) {
|
|||||||
auth: auth
|
auth: auth
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (config.socketPath) {
|
||||||
|
options.socketPath = config.socketPath;
|
||||||
|
} else {
|
||||||
|
options.hostname = parsed.hostname;
|
||||||
|
options.port = parsed.port;
|
||||||
|
}
|
||||||
|
|
||||||
var proxy = config.proxy;
|
var proxy = config.proxy;
|
||||||
if (!proxy && proxy !== false) {
|
if (!proxy && proxy !== false) {
|
||||||
var proxyEnv = protocol.slice(0, -1) + '_proxy';
|
var proxyEnv = protocol.slice(0, -1) + '_proxy';
|
||||||
@@ -117,7 +122,9 @@ module.exports = function httpAdapter(config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var transport;
|
var transport;
|
||||||
if (config.maxRedirects === 0) {
|
if (config.transport) {
|
||||||
|
transport = config.transport;
|
||||||
|
} else if (config.maxRedirects === 0) {
|
||||||
transport = isHttps ? https : http;
|
transport = isHttps ? https : http;
|
||||||
} else {
|
} else {
|
||||||
if (config.maxRedirects) {
|
if (config.maxRedirects) {
|
||||||
@@ -126,6 +133,10 @@ module.exports = function httpAdapter(config) {
|
|||||||
transport = isHttps ? httpsFollow : httpFollow;
|
transport = isHttps ? httpsFollow : httpFollow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.maxContentLength && config.maxContentLength > -1) {
|
||||||
|
options.maxBodyLength = config.maxContentLength;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the request
|
// Create the request
|
||||||
var req = transport.request(options, function handleResponse(res) {
|
var req = transport.request(options, function handleResponse(res) {
|
||||||
if (req.aborted) return;
|
if (req.aborted) return;
|
||||||
|
|||||||
+1
-2
@@ -24,8 +24,7 @@ module.exports = function xhrAdapter(config) {
|
|||||||
// For IE 8/9 CORS support
|
// For IE 8/9 CORS support
|
||||||
// Only supports POST and GET calls and doesn't returns the response headers.
|
// Only supports POST and GET calls and doesn't returns the response headers.
|
||||||
// DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
|
// DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
|
||||||
if (!window.XMLHttpRequest &&
|
if (process.env.NODE_ENV !== 'test' &&
|
||||||
process.env.NODE_ENV !== 'test' &&
|
|
||||||
typeof window !== 'undefined' &&
|
typeof window !== 'undefined' &&
|
||||||
window.XDomainRequest && !('withCredentials' in request) &&
|
window.XDomainRequest && !('withCredentials' in request) &&
|
||||||
!isURLSameOrigin(config.url)) {
|
!isURLSameOrigin(config.url)) {
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ var defaults = {
|
|||||||
return data;
|
return data;
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
||||||
|
* timeout is not created.
|
||||||
|
*/
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
|
|
||||||
xsrfCookieName: 'XSRF-TOKEN',
|
xsrfCookieName: 'XSRF-TOKEN',
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ module.exports = function buildURL(url, params, paramsSerializer) {
|
|||||||
|
|
||||||
if (utils.isArray(val)) {
|
if (utils.isArray(val)) {
|
||||||
key = key + '[]';
|
key = key + '[]';
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (!utils.isArray(val)) {
|
|
||||||
val = [val];
|
val = [val];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -207,7 +207,7 @@ function forEach(obj, fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Force an array if not already something iterable
|
// Force an array if not already something iterable
|
||||||
if (typeof obj !== 'object' && !isArray(obj)) {
|
if (typeof obj !== 'object') {
|
||||||
/*eslint no-param-reassign:0*/
|
/*eslint no-param-reassign:0*/
|
||||||
obj = [obj];
|
obj = [obj];
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "axios",
|
"name": "axios",
|
||||||
"version": "0.16.2",
|
"version": "0.18.0",
|
||||||
"description": "Promise based HTTP client for the browser and node.js",
|
"description": "Promise based HTTP client for the browser and node.js",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -53,7 +53,6 @@
|
|||||||
"karma-jasmine": "^1.0.2",
|
"karma-jasmine": "^1.0.2",
|
||||||
"karma-jasmine-ajax": "^0.1.13",
|
"karma-jasmine-ajax": "^0.1.13",
|
||||||
"karma-opera-launcher": "^1.0.0",
|
"karma-opera-launcher": "^1.0.0",
|
||||||
"karma-phantomjs-launcher": "^1.0.0",
|
|
||||||
"karma-safari-launcher": "^1.0.0",
|
"karma-safari-launcher": "^1.0.0",
|
||||||
"karma-sauce-launcher": "^1.1.0",
|
"karma-sauce-launcher": "^1.1.0",
|
||||||
"karma-sinon": "^1.0.5",
|
"karma-sinon": "^1.0.5",
|
||||||
@@ -61,7 +60,6 @@
|
|||||||
"karma-webpack": "^1.7.0",
|
"karma-webpack": "^1.7.0",
|
||||||
"load-grunt-tasks": "^3.5.2",
|
"load-grunt-tasks": "^3.5.2",
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
"phantomjs-prebuilt": "^2.1.7",
|
|
||||||
"sinon": "^1.17.4",
|
"sinon": "^1.17.4",
|
||||||
"webpack": "^1.13.1",
|
"webpack": "^1.13.1",
|
||||||
"webpack-dev-server": "^1.14.1",
|
"webpack-dev-server": "^1.14.1",
|
||||||
@@ -73,7 +71,7 @@
|
|||||||
},
|
},
|
||||||
"typings": "./index.d.ts",
|
"typings": "./index.d.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.2.3",
|
"follow-redirects": "^1.3.0",
|
||||||
"is-buffer": "^1.1.5"
|
"is-buffer": "^1.1.5"
|
||||||
},
|
},
|
||||||
"bundlesize": [
|
"bundlesize": [
|
||||||
|
|||||||
@@ -97,11 +97,54 @@ axios.patch('/user', { foo: 'bar' })
|
|||||||
.then(handleResponse)
|
.then(handleResponse)
|
||||||
.catch(handleError);
|
.catch(handleError);
|
||||||
|
|
||||||
|
// Typed methods
|
||||||
|
interface User {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleUserResponse = (response: AxiosResponse<User>) => {
|
||||||
|
console.log(response.data.id);
|
||||||
|
console.log(response.data.name);
|
||||||
|
console.log(response.status);
|
||||||
|
console.log(response.statusText);
|
||||||
|
console.log(response.headers);
|
||||||
|
console.log(response.config);
|
||||||
|
};
|
||||||
|
|
||||||
|
axios.get<User>('/user?id=12345')
|
||||||
|
.then(handleUserResponse)
|
||||||
|
.catch(handleError);
|
||||||
|
|
||||||
|
axios.get<User>('/user', { params: { id: 12345 } })
|
||||||
|
.then(handleUserResponse)
|
||||||
|
.catch(handleError);
|
||||||
|
|
||||||
|
axios.post<User>('/user', { foo: 'bar' })
|
||||||
|
.then(handleUserResponse)
|
||||||
|
.catch(handleError);
|
||||||
|
|
||||||
|
axios.post<User>('/user', { foo: 'bar' }, { headers: { 'X-FOO': 'bar' } })
|
||||||
|
.then(handleUserResponse)
|
||||||
|
.catch(handleError);
|
||||||
|
|
||||||
|
axios.put<User>('/user', { foo: 'bar' })
|
||||||
|
.then(handleUserResponse)
|
||||||
|
.catch(handleError);
|
||||||
|
|
||||||
|
axios.patch<User>('/user', { foo: 'bar' })
|
||||||
|
.then(handleUserResponse)
|
||||||
|
.catch(handleError);
|
||||||
|
|
||||||
// Instances
|
// Instances
|
||||||
|
|
||||||
const instance1: AxiosInstance = axios.create();
|
const instance1: AxiosInstance = axios.create();
|
||||||
const instance2: AxiosInstance = axios.create(config);
|
const instance2: AxiosInstance = axios.create(config);
|
||||||
|
|
||||||
|
instance1(config)
|
||||||
|
.then(handleResponse)
|
||||||
|
.catch(handleError);
|
||||||
|
|
||||||
instance1.request(config)
|
instance1.request(config)
|
||||||
.then(handleResponse)
|
.then(handleResponse)
|
||||||
.catch(handleError);
|
.catch(handleError);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
var axios = require('../../../index');
|
var axios = require('../../../index');
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
|
var net = require('net');
|
||||||
var url = require('url');
|
var url = require('url');
|
||||||
var zlib = require('zlib');
|
var zlib = require('zlib');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
@@ -228,6 +229,24 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
testSocket: function (test) {
|
||||||
|
server = net.createServer(function (socket) {
|
||||||
|
socket.on('data', function() {
|
||||||
|
socket.end('HTTP/1.1 200 OK\r\n\r\n');
|
||||||
|
});
|
||||||
|
}).listen('./test.sock', function() {
|
||||||
|
axios({
|
||||||
|
socketPath: './test.sock',
|
||||||
|
url: '/'
|
||||||
|
})
|
||||||
|
.then(function(resp) {
|
||||||
|
test.equal(resp.status, 200);
|
||||||
|
test.equal(resp.statusText, 'OK');
|
||||||
|
test.done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
testStream: function(test) {
|
testStream: function(test) {
|
||||||
server = http.createServer(function (req, res) {
|
server = http.createServer(function (req, res) {
|
||||||
req.pipe(res);
|
req.pipe(res);
|
||||||
|
|||||||
Reference in New Issue
Block a user