mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Renaming options to config
This commit is contained in:
Vendored
+27
-27
@@ -59,27 +59,27 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
var urlIsSameOrigin = __webpack_require__(7);
|
var urlIsSameOrigin = __webpack_require__(7);
|
||||||
var utils = __webpack_require__(8);
|
var utils = __webpack_require__(8);
|
||||||
|
|
||||||
var axios = module.exports = function axios(options) {
|
var axios = module.exports = function axios(config) {
|
||||||
options = utils.merge({
|
config = utils.merge({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
transformRequest: defaults.transformRequest,
|
transformRequest: defaults.transformRequest,
|
||||||
transformResponse: defaults.transformResponse
|
transformResponse: defaults.transformResponse
|
||||||
}, options);
|
}, config);
|
||||||
|
|
||||||
// Don't allow overriding defaults.withCredentials
|
// Don't allow overriding defaults.withCredentials
|
||||||
options.withCredentials = options.withCredentials || defaults.withCredentials;
|
config.withCredentials = config.withCredentials || defaults.withCredentials;
|
||||||
|
|
||||||
var promise = new Promise(function (resolve, reject) {
|
var promise = new Promise(function (resolve, reject) {
|
||||||
// Create the request
|
// Create the request
|
||||||
var request = new(XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
|
var request = new(XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
|
||||||
var data = transformData(
|
var data = transformData(
|
||||||
options.data,
|
config.data,
|
||||||
options.headers,
|
config.headers,
|
||||||
options.transformRequest
|
config.transformRequest
|
||||||
);
|
);
|
||||||
|
|
||||||
// Open the request
|
// Open the request
|
||||||
request.open(options.method, buildUrl(options.url, options.params), true);
|
request.open(config.method, buildUrl(config.url, config.params), true);
|
||||||
|
|
||||||
// Listen for ready state
|
// Listen for ready state
|
||||||
request.onreadystatechange = function () {
|
request.onreadystatechange = function () {
|
||||||
@@ -90,11 +90,11 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
data: transformData(
|
data: transformData(
|
||||||
request.responseText,
|
request.responseText,
|
||||||
headers,
|
headers,
|
||||||
options.transformResponse
|
config.transformResponse
|
||||||
),
|
),
|
||||||
status: request.status,
|
status: request.status,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
config: options
|
config: config
|
||||||
};
|
};
|
||||||
|
|
||||||
// Resolve or reject the Promise based on the status
|
// Resolve or reject the Promise based on the status
|
||||||
@@ -112,16 +112,16 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
// Merge headers and add to request
|
// Merge headers and add to request
|
||||||
var headers = utils.merge(
|
var headers = utils.merge(
|
||||||
defaults.headers.common,
|
defaults.headers.common,
|
||||||
defaults.headers[options.method] || {},
|
defaults.headers[config.method] || {},
|
||||||
options.headers || {}
|
config.headers || {}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add xsrf header
|
// Add xsrf header
|
||||||
var xsrfValue = urlIsSameOrigin(options.url)
|
var xsrfValue = urlIsSameOrigin(config.url)
|
||||||
? cookies.read(options.xsrfCookieName || defaults.xsrfCookieName)
|
? cookies.read(config.xsrfCookieName || defaults.xsrfCookieName)
|
||||||
: undefined;
|
: undefined;
|
||||||
if (xsrfValue) {
|
if (xsrfValue) {
|
||||||
headers[options.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
|
headers[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.forEach(headers, function (val, key) {
|
utils.forEach(headers, function (val, key) {
|
||||||
@@ -136,14 +136,14 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Add withCredentials to request if needed
|
// Add withCredentials to request if needed
|
||||||
if (options.withCredentials) {
|
if (config.withCredentials) {
|
||||||
request.withCredentials = true;
|
request.withCredentials = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add responseType to request if needed
|
// Add responseType to request if needed
|
||||||
if (options.responseType) {
|
if (config.responseType) {
|
||||||
try {
|
try {
|
||||||
request.responseType = options.responseType;
|
request.responseType = config.responseType;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (request.responseType !== 'json') {
|
if (request.responseType !== 'json') {
|
||||||
throw e;
|
throw e;
|
||||||
@@ -183,8 +183,8 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
|
|
||||||
function createShortMethods() {
|
function createShortMethods() {
|
||||||
utils.forEach(arguments, function (method) {
|
utils.forEach(arguments, function (method) {
|
||||||
axios[method] = function (url, options) {
|
axios[method] = function (url, config) {
|
||||||
return axios(utils.merge(options || {}, {
|
return axios(utils.merge(config || {}, {
|
||||||
method: method,
|
method: method,
|
||||||
url: url
|
url: url
|
||||||
}));
|
}));
|
||||||
@@ -194,8 +194,8 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
|
|
||||||
function createShortMethodsWithData() {
|
function createShortMethodsWithData() {
|
||||||
utils.forEach(arguments, function (method) {
|
utils.forEach(arguments, function (method) {
|
||||||
axios[method] = function (url, data, options) {
|
axios[method] = function (url, data, config) {
|
||||||
return axios(utils.merge(options || {}, {
|
return axios(utils.merge(config || {}, {
|
||||||
method: method,
|
method: method,
|
||||||
url: url,
|
url: url,
|
||||||
data: data
|
data: data
|
||||||
@@ -263,12 +263,12 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
var utils = __webpack_require__(8);
|
var utils = __webpack_require__(8);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
write: function (name, value, expires, path, domain, secure) {
|
write: function write(name, value, expires, path, domain, secure) {
|
||||||
var cookie = [];
|
var cookie = [];
|
||||||
cookie.push(name + '=' + encodeURIComponent(value));
|
cookie.push(name + '=' + encodeURIComponent(value));
|
||||||
|
|
||||||
if (utils.isNumber(expires)) {
|
if (utils.isNumber(expires)) {
|
||||||
cookie.push('expires=' + new Date(exires).toGMTString());
|
cookie.push('expires=' + new Date(expires).toGMTString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utils.isString(path)) {
|
if (utils.isString(path)) {
|
||||||
@@ -286,12 +286,12 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
document.cookie = cookie.join('; ');
|
document.cookie = cookie.join('; ');
|
||||||
},
|
},
|
||||||
|
|
||||||
read: function (name) {
|
read: function read(name) {
|
||||||
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
||||||
return (match ? decodeURIComponent(match[3]) : null);
|
return (match ? decodeURIComponent(match[3]) : null);
|
||||||
},
|
},
|
||||||
|
|
||||||
remove: function (name) {
|
remove: function remove(name) {
|
||||||
this.write(name, '', Date.now() - 86400000);
|
this.write(name, '', Date.now() - 86400000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -411,7 +411,7 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var msie = /trident/i.test(navigator.userAgent);
|
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
||||||
var utils = __webpack_require__(8);
|
var utils = __webpack_require__(8);
|
||||||
var urlParsingNode = document.createElement('a');
|
var urlParsingNode = document.createElement('a');
|
||||||
var originUrl = urlResolve(window.location.href);
|
var originUrl = urlResolve(window.location.href);
|
||||||
|
|||||||
Vendored
+1
-1
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
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+22
-22
@@ -60,27 +60,27 @@ var axios =
|
|||||||
var urlIsSameOrigin = __webpack_require__(7);
|
var urlIsSameOrigin = __webpack_require__(7);
|
||||||
var utils = __webpack_require__(8);
|
var utils = __webpack_require__(8);
|
||||||
|
|
||||||
var axios = module.exports = function axios(options) {
|
var axios = module.exports = function axios(config) {
|
||||||
options = utils.merge({
|
config = utils.merge({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
transformRequest: defaults.transformRequest,
|
transformRequest: defaults.transformRequest,
|
||||||
transformResponse: defaults.transformResponse
|
transformResponse: defaults.transformResponse
|
||||||
}, options);
|
}, config);
|
||||||
|
|
||||||
// Don't allow overriding defaults.withCredentials
|
// Don't allow overriding defaults.withCredentials
|
||||||
options.withCredentials = options.withCredentials || defaults.withCredentials;
|
config.withCredentials = config.withCredentials || defaults.withCredentials;
|
||||||
|
|
||||||
var promise = new Promise(function (resolve, reject) {
|
var promise = new Promise(function (resolve, reject) {
|
||||||
// Create the request
|
// Create the request
|
||||||
var request = new(XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
|
var request = new(XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
|
||||||
var data = transformData(
|
var data = transformData(
|
||||||
options.data,
|
config.data,
|
||||||
options.headers,
|
config.headers,
|
||||||
options.transformRequest
|
config.transformRequest
|
||||||
);
|
);
|
||||||
|
|
||||||
// Open the request
|
// Open the request
|
||||||
request.open(options.method, buildUrl(options.url, options.params), true);
|
request.open(config.method, buildUrl(config.url, config.params), true);
|
||||||
|
|
||||||
// Listen for ready state
|
// Listen for ready state
|
||||||
request.onreadystatechange = function () {
|
request.onreadystatechange = function () {
|
||||||
@@ -91,11 +91,11 @@ var axios =
|
|||||||
data: transformData(
|
data: transformData(
|
||||||
request.responseText,
|
request.responseText,
|
||||||
headers,
|
headers,
|
||||||
options.transformResponse
|
config.transformResponse
|
||||||
),
|
),
|
||||||
status: request.status,
|
status: request.status,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
config: options
|
config: config
|
||||||
};
|
};
|
||||||
|
|
||||||
// Resolve or reject the Promise based on the status
|
// Resolve or reject the Promise based on the status
|
||||||
@@ -113,16 +113,16 @@ var axios =
|
|||||||
// Merge headers and add to request
|
// Merge headers and add to request
|
||||||
var headers = utils.merge(
|
var headers = utils.merge(
|
||||||
defaults.headers.common,
|
defaults.headers.common,
|
||||||
defaults.headers[options.method] || {},
|
defaults.headers[config.method] || {},
|
||||||
options.headers || {}
|
config.headers || {}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add xsrf header
|
// Add xsrf header
|
||||||
var xsrfValue = urlIsSameOrigin(options.url)
|
var xsrfValue = urlIsSameOrigin(config.url)
|
||||||
? cookies.read(options.xsrfCookieName || defaults.xsrfCookieName)
|
? cookies.read(config.xsrfCookieName || defaults.xsrfCookieName)
|
||||||
: undefined;
|
: undefined;
|
||||||
if (xsrfValue) {
|
if (xsrfValue) {
|
||||||
headers[options.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
|
headers[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.forEach(headers, function (val, key) {
|
utils.forEach(headers, function (val, key) {
|
||||||
@@ -137,14 +137,14 @@ var axios =
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Add withCredentials to request if needed
|
// Add withCredentials to request if needed
|
||||||
if (options.withCredentials) {
|
if (config.withCredentials) {
|
||||||
request.withCredentials = true;
|
request.withCredentials = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add responseType to request if needed
|
// Add responseType to request if needed
|
||||||
if (options.responseType) {
|
if (config.responseType) {
|
||||||
try {
|
try {
|
||||||
request.responseType = options.responseType;
|
request.responseType = config.responseType;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (request.responseType !== 'json') {
|
if (request.responseType !== 'json') {
|
||||||
throw e;
|
throw e;
|
||||||
@@ -184,8 +184,8 @@ var axios =
|
|||||||
|
|
||||||
function createShortMethods() {
|
function createShortMethods() {
|
||||||
utils.forEach(arguments, function (method) {
|
utils.forEach(arguments, function (method) {
|
||||||
axios[method] = function (url, options) {
|
axios[method] = function (url, config) {
|
||||||
return axios(utils.merge(options || {}, {
|
return axios(utils.merge(config || {}, {
|
||||||
method: method,
|
method: method,
|
||||||
url: url
|
url: url
|
||||||
}));
|
}));
|
||||||
@@ -195,8 +195,8 @@ var axios =
|
|||||||
|
|
||||||
function createShortMethodsWithData() {
|
function createShortMethodsWithData() {
|
||||||
utils.forEach(arguments, function (method) {
|
utils.forEach(arguments, function (method) {
|
||||||
axios[method] = function (url, data, options) {
|
axios[method] = function (url, data, config) {
|
||||||
return axios(utils.merge(options || {}, {
|
return axios(utils.merge(config || {}, {
|
||||||
method: method,
|
method: method,
|
||||||
url: url,
|
url: url,
|
||||||
data: data
|
data: data
|
||||||
|
|||||||
Vendored
+1
-1
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
+1
-1
File diff suppressed because one or more lines are too long
+22
-22
@@ -7,27 +7,27 @@ var transformData = require('./transformData');
|
|||||||
var urlIsSameOrigin = require('./urlIsSameOrigin');
|
var urlIsSameOrigin = require('./urlIsSameOrigin');
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
|
|
||||||
var axios = module.exports = function axios(options) {
|
var axios = module.exports = function axios(config) {
|
||||||
options = utils.merge({
|
config = utils.merge({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
transformRequest: defaults.transformRequest,
|
transformRequest: defaults.transformRequest,
|
||||||
transformResponse: defaults.transformResponse
|
transformResponse: defaults.transformResponse
|
||||||
}, options);
|
}, config);
|
||||||
|
|
||||||
// Don't allow overriding defaults.withCredentials
|
// Don't allow overriding defaults.withCredentials
|
||||||
options.withCredentials = options.withCredentials || defaults.withCredentials;
|
config.withCredentials = config.withCredentials || defaults.withCredentials;
|
||||||
|
|
||||||
var promise = new Promise(function (resolve, reject) {
|
var promise = new Promise(function (resolve, reject) {
|
||||||
// Create the request
|
// Create the request
|
||||||
var request = new(XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
|
var request = new(XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
|
||||||
var data = transformData(
|
var data = transformData(
|
||||||
options.data,
|
config.data,
|
||||||
options.headers,
|
config.headers,
|
||||||
options.transformRequest
|
config.transformRequest
|
||||||
);
|
);
|
||||||
|
|
||||||
// Open the request
|
// Open the request
|
||||||
request.open(options.method, buildUrl(options.url, options.params), true);
|
request.open(config.method, buildUrl(config.url, config.params), true);
|
||||||
|
|
||||||
// Listen for ready state
|
// Listen for ready state
|
||||||
request.onreadystatechange = function () {
|
request.onreadystatechange = function () {
|
||||||
@@ -38,11 +38,11 @@ var axios = module.exports = function axios(options) {
|
|||||||
data: transformData(
|
data: transformData(
|
||||||
request.responseText,
|
request.responseText,
|
||||||
headers,
|
headers,
|
||||||
options.transformResponse
|
config.transformResponse
|
||||||
),
|
),
|
||||||
status: request.status,
|
status: request.status,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
config: options
|
config: config
|
||||||
};
|
};
|
||||||
|
|
||||||
// Resolve or reject the Promise based on the status
|
// Resolve or reject the Promise based on the status
|
||||||
@@ -60,16 +60,16 @@ var axios = module.exports = function axios(options) {
|
|||||||
// Merge headers and add to request
|
// Merge headers and add to request
|
||||||
var headers = utils.merge(
|
var headers = utils.merge(
|
||||||
defaults.headers.common,
|
defaults.headers.common,
|
||||||
defaults.headers[options.method] || {},
|
defaults.headers[config.method] || {},
|
||||||
options.headers || {}
|
config.headers || {}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add xsrf header
|
// Add xsrf header
|
||||||
var xsrfValue = urlIsSameOrigin(options.url)
|
var xsrfValue = urlIsSameOrigin(config.url)
|
||||||
? cookies.read(options.xsrfCookieName || defaults.xsrfCookieName)
|
? cookies.read(config.xsrfCookieName || defaults.xsrfCookieName)
|
||||||
: undefined;
|
: undefined;
|
||||||
if (xsrfValue) {
|
if (xsrfValue) {
|
||||||
headers[options.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
|
headers[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.forEach(headers, function (val, key) {
|
utils.forEach(headers, function (val, key) {
|
||||||
@@ -84,14 +84,14 @@ var axios = module.exports = function axios(options) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Add withCredentials to request if needed
|
// Add withCredentials to request if needed
|
||||||
if (options.withCredentials) {
|
if (config.withCredentials) {
|
||||||
request.withCredentials = true;
|
request.withCredentials = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add responseType to request if needed
|
// Add responseType to request if needed
|
||||||
if (options.responseType) {
|
if (config.responseType) {
|
||||||
try {
|
try {
|
||||||
request.responseType = options.responseType;
|
request.responseType = config.responseType;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (request.responseType !== 'json') {
|
if (request.responseType !== 'json') {
|
||||||
throw e;
|
throw e;
|
||||||
@@ -131,8 +131,8 @@ createShortMethodsWithData('post', 'put', 'patch');
|
|||||||
|
|
||||||
function createShortMethods() {
|
function createShortMethods() {
|
||||||
utils.forEach(arguments, function (method) {
|
utils.forEach(arguments, function (method) {
|
||||||
axios[method] = function (url, options) {
|
axios[method] = function (url, config) {
|
||||||
return axios(utils.merge(options || {}, {
|
return axios(utils.merge(config || {}, {
|
||||||
method: method,
|
method: method,
|
||||||
url: url
|
url: url
|
||||||
}));
|
}));
|
||||||
@@ -142,8 +142,8 @@ function createShortMethods() {
|
|||||||
|
|
||||||
function createShortMethodsWithData() {
|
function createShortMethodsWithData() {
|
||||||
utils.forEach(arguments, function (method) {
|
utils.forEach(arguments, function (method) {
|
||||||
axios[method] = function (url, data, options) {
|
axios[method] = function (url, data, config) {
|
||||||
return axios(utils.merge(options || {}, {
|
return axios(utils.merge(config || {}, {
|
||||||
method: method,
|
method: method,
|
||||||
url: url,
|
url: url,
|
||||||
data: data
|
data: data
|
||||||
|
|||||||
Reference in New Issue
Block a user