Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

http_proxy.txt

34

axios.d.ts

@@ -1,2 +0,2 @@

// Type definitions for Axios v0.7.0
// Type definitions for Axios v0.8.0
// Project: https://github.com/mzabriskie/axios

@@ -9,4 +9,3 @@

declare module axios {
interface AxiosStatic {
(options: axios.RequestOptions): axios.Promise;
interface AxiosRequestMethods {
get(url: string, config?: any): axios.Promise;

@@ -18,9 +17,19 @@ delete(url: string, config?: any): axios.Promise;

patch(url: string, data: any, config?: any): axios.Promise;
}
interface AxiosStatic extends AxiosRequestMethods {
(options: axios.RequestOptions): axios.Promise;
create(defaultOptions?: axios.InstanceOptions): AxiosInstance;
all(iterable: any): axios.Promise;
spread(callback: any): axios.Promise;
}
interface AxiosInstance extends AxiosRequestMethods {
request(options: axios.RequestOptions): axios.Promise;
}
interface Response {
data?: any;
status?: number;
statusText?: string;
headers?: any;

@@ -35,9 +44,7 @@ config?: any;

interface RequestOptions {
url: string;
method?: string;
interface InstanceOptions {
transformRequest?: (data: any) => any;
transformResponse?: (data: any) => any;
headers?: any;
params?: any;
data?: any;
timeout?: number;
withCredentials?: boolean;

@@ -47,3 +54,12 @@ responseType?: string;

xsrfHeaderName?: string;
paramsSerializer?: (params: any) => string;
baseURL?: string;
}
interface RequestOptions extends InstanceOptions {
url: string;
method?: string;
params?: any;
data?: any;
}
}

@@ -50,0 +66,0 @@

@@ -92,1 +92,13 @@ # Changelog

- Adding support for fetch like API `axios(url[, config])` ([#116](https://github.com/mzabriskie/axios/issues/116))
### 0.8.0 (Dec 11, 2015)
- Adding support for creating instances of axios ([#123](https://github.com/mzabriskie/axios/pull/123))
- Fixing http adapter to use `Buffer` instead of `String` in case of `responseType === 'arraybuffer'` ([#128](https://github.com/mzabriskie/axios/pull/128))
- Adding support for using custom parameter serializer with `paramsSerializer` option ([#121](https://github.com/mzabriskie/axios/pull/121))
- Fixing issue in IE8 caused by `forEach` on `arguments` ([#127](https://github.com/mzabriskie/axios/pull/127))
- Adding support for following redirects in node ([#146](https://github.com/mzabriskie/axios/pull/146))
- Adding support for transparent decompression if `content-encoding` is set ([#149](https://github.com/mzabriskie/axios/pull/149))
- Adding support for transparent XDomainRequest to handle cross domain requests in IE9 ([#140](https://github.com/mzabriskie/axios/pull/140))
- Adding support for HTTP basic auth via Authorization header ([#167](https://github.com/mzabriskie/axios/pull/167))
- Adding support for baseURL option ([#160](https://github.com/mzabriskie/axios/pull/160))

@@ -1,2 +0,2 @@

/* axios v0.7.0 | (c) 2015 by Matt Zabriskie */
/* axios v0.8.0 | (c) 2015 by Matt Zabriskie */
(function webpackUniversalModuleDefinition(root, factory) {

@@ -70,4 +70,20 @@ if(typeof exports === 'object' && typeof module === 'object')

var InterceptorManager = __webpack_require__(12);
var isAbsoluteURL = __webpack_require__(13);
var combineURLs = __webpack_require__(14);
var axios = module.exports = function (config) {
function Axios (defaultConfig) {
this.defaultConfig = utils.merge({
headers: {},
timeout: defaults.timeout,
transformRequest: defaults.transformRequest,
transformResponse: defaults.transformResponse
}, defaultConfig);
this.interceptors = {
request: new InterceptorManager(),
response: new InterceptorManager()
};
}
Axios.prototype.request = function (config) {
// Allow for axios('example/url'[, config]) a la fetch API

@@ -80,10 +96,8 @@ if (typeof config === 'string') {

config = utils.merge({
method: 'get',
headers: {},
timeout: defaults.timeout,
transformRequest: defaults.transformRequest,
transformResponse: defaults.transformResponse
}, config);
config = utils.merge(this.defaultConfig, { method: 'get' }, config);
if (config.baseURL && !isAbsoluteURL(config.url)) {
config.url = combineURLs(config.baseURL, config.url);
}
// Don't allow overriding defaults.withCredentials

@@ -96,7 +110,7 @@ config.withCredentials = config.withCredentials || defaults.withCredentials;

axios.interceptors.request.forEach(function (interceptor) {
this.interceptors.request.forEach(function (interceptor) {
chain.unshift(interceptor.fulfilled, interceptor.rejected);
});
axios.interceptors.response.forEach(function (interceptor) {
this.interceptors.response.forEach(function (interceptor) {
chain.push(interceptor.fulfilled, interceptor.rejected);

@@ -112,2 +126,10 @@ });

var defaultInstance = new Axios();
var axios = module.exports = bind(Axios.prototype.request, defaultInstance);
axios.create = function (defaultConfig) {
return new Axios(defaultConfig);
};
// Expose defaults

@@ -120,38 +142,39 @@ axios.defaults = defaults;

};
axios.spread = __webpack_require__(13);
axios.spread = __webpack_require__(15);
// Expose interceptors
axios.interceptors = {
request: new InterceptorManager(),
response: new InterceptorManager()
};
axios.interceptors = defaultInstance.interceptors;
// Helpers
function bind (fn, thisArg) {
return function () {
var args = new Array(arguments.length);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i];
}
return fn.apply(thisArg, args);
};
}
// Provide aliases for supported request methods
(function () {
function createShortMethods() {
utils.forEach(arguments, function (method) {
axios[method] = function (url, config) {
return axios(utils.merge(config || {}, {
method: method,
url: url
}));
};
});
}
utils.forEach(['delete', 'get', 'head'], function (method) {
Axios.prototype[method] = function (url, config) {
return this.request(utils.merge(config || {}, {
method: method,
url: url
}));
};
axios[method] = bind(Axios.prototype[method], defaultInstance);
});
function createShortMethodsWithData() {
utils.forEach(arguments, function (method) {
axios[method] = function (url, data, config) {
return axios(utils.merge(config || {}, {
method: method,
url: url,
data: data
}));
};
});
}
createShortMethods('delete', 'get', 'head');
createShortMethodsWithData('post', 'put', 'patch');
})();
utils.forEach(['post', 'put', 'patch'], function (method) {
Axios.prototype[method] = function (url, data, config) {
return this.request(utils.merge(config || {}, {
method: method,
url: url,
data: data
}));
};
axios[method] = bind(Axios.prototype[method], defaultInstance);
});

@@ -364,12 +387,2 @@

/**
* Determine if a value is an Arguments object
*
* @param {Object} val The value to test
* @returns {boolean} True if value is an Arguments object, otherwise false
*/
function isArguments(val) {
return toString.call(val) === '[object Arguments]';
}
/**
* Determine if we're running in a standard browser environment

@@ -385,3 +398,3 @@ *

* react-native:
* typeof document.createelement -> undefined
* typeof document.createElement -> undefined
*/

@@ -399,3 +412,3 @@ function isStandardBrowserEnv() {

*
* If `obj` is an Array or arguments callback will be called passing
* If `obj` is an Array callback will be called passing
* the value, index, and complete array for each item.

@@ -415,7 +428,4 @@ *

// Check if obj is array-like
var isArrayLike = isArray(obj) || isArguments(obj);
// Force an array if not already something iterable
if (typeof obj !== 'object' && !isArrayLike) {
if (typeof obj !== 'object' && !isArray(obj)) {
obj = [obj];

@@ -425,3 +435,3 @@ }

// Iterate over array values
if (isArrayLike) {
if (isArray(obj)) {
for (var i = 0, l = obj.length; i < l; i++) {

@@ -460,7 +470,7 @@ fn.call(null, obj[i], i, obj);

var result = {};
forEach(arguments, function (obj) {
forEach(obj, function (val, key) {
result[key] = val;
});
});
var assignValue = function (val, key) { result[key] = val; };
var length = arguments.length;
for (var i = 0; i < length; i++) {
forEach(arguments[i], assignValue);
}
return result;

@@ -492,3 +502,3 @@ }

/* WEBPACK VAR INJECTION */(function(process) {'use strict';
'use strict';

@@ -507,7 +517,7 @@ /**

if ((typeof XMLHttpRequest !== 'undefined') || (typeof ActiveXObject !== 'undefined')) {
__webpack_require__(6)(resolve, reject, config);
__webpack_require__(5)(resolve, reject, config);
}
// For node use HTTP adapter
else if (typeof process !== 'undefined') {
__webpack_require__(6)(resolve, reject, config);
__webpack_require__(5)(resolve, reject, config);
}

@@ -520,104 +530,6 @@ } catch (e) {

/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)))
/***/ },
/* 5 */
/***/ function(module, exports) {
// shim for using process in browser
var process = module.exports = {};
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = setTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
clearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
setTimeout(drainQueue, 0);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {

@@ -631,5 +543,7 @@

var utils = __webpack_require__(3);
var buildUrl = __webpack_require__(7);
var parseHeaders = __webpack_require__(8);
var transformData = __webpack_require__(9);
var buildURL = __webpack_require__(6);
var parseHeaders = __webpack_require__(7);
var transformData = __webpack_require__(8);
var isURLSameOrigin = __webpack_require__(9);
var btoa = window.btoa || __webpack_require__(10)

@@ -655,5 +569,23 @@ module.exports = function xhrAdapter(resolve, reject, config) {

var adapter = (XMLHttpRequest || ActiveXObject);
var loadEvent = 'onreadystatechange';
var xDomain = false;
// For IE 8/9 CORS support
if(!isURLSameOrigin(config.url) && window.XDomainRequest){
adapter = window.XDomainRequest;
loadEvent = 'onload';
xDomain = true;
}
// HTTP basic authentication
if (config.auth) {
var username = config.auth.username || '';
var password = config.auth.password || '';
requestHeaders['Authorization'] = 'Basic: ' + btoa(username + ':' + password);
}
// Create the request
var request = new (XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
request.open(config.method.toUpperCase(), buildUrl(config.url, config.params), true);
var request = new adapter('Microsoft.XMLHTTP');
request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);

@@ -664,6 +596,6 @@ // Set the request timeout in MS

// Listen for ready state
request.onreadystatechange = function () {
if (request && request.readyState === 4) {
request[loadEvent] = function () {
if (request && (request.readyState === 4 || xDomain)) {
// Prepare the response
var responseHeaders = parseHeaders(request.getAllResponseHeaders());
var responseHeaders = xDomain ? null : parseHeaders(request.getAllResponseHeaders());
var responseData = ['text', ''].indexOf(config.responseType || '') !== -1 ? request.responseText : request.response;

@@ -681,5 +613,4 @@ var response = {

};
// Resolve or reject the Promise based on the status
(request.status >= 200 && request.status < 300 ?
((request.status >= 200 && request.status < 300) || (request.responseText && xDomain) ?
resolve :

@@ -697,7 +628,6 @@ reject)(response);

if (utils.isStandardBrowserEnv()) {
var cookies = __webpack_require__(10);
var urlIsSameOrigin = __webpack_require__(11);
var cookies = __webpack_require__(11);
// Add xsrf header
var xsrfValue = urlIsSameOrigin(config.url) ?
var xsrfValue = isURLSameOrigin(config.url) ?
cookies.read(config.xsrfCookieName || defaults.xsrfCookieName) :

@@ -712,12 +642,13 @@ undefined;

// Add headers to the request
utils.forEach(requestHeaders, function (val, key) {
// Remove Content-Type if data is undefined
if (!data && key.toLowerCase() === 'content-type') {
delete requestHeaders[key];
}
// Otherwise add header to the request
else {
request.setRequestHeader(key, val);
}
});
if(!xDomain)
utils.forEach(requestHeaders, function (val, key) {
// Remove Content-Type if data is undefined
if (!data && key.toLowerCase() === 'content-type') {
delete requestHeaders[key];
}
// Otherwise add header to the request
else {
request.setRequestHeader(key, val);
}
});

@@ -750,3 +681,3 @@ // Add withCredentials to request if needed

/***/ },
/* 7 */
/* 6 */
/***/ function(module, exports, __webpack_require__) {

@@ -776,3 +707,3 @@

*/
module.exports = function buildUrl(url, params) {
module.exports = function buildURL(url, params, paramsSerializer) {
if (!params) {

@@ -782,38 +713,47 @@ return url;

var parts = [];
var serializedParams;
if (paramsSerializer) {
serializedParams = paramsSerializer(params);
}
else {
var parts = [];
utils.forEach(params, function (val, key) {
if (val === null || typeof val === 'undefined') {
return;
}
utils.forEach(params, function (val, key) {
if (val === null || typeof val === 'undefined') {
return;
}
if (utils.isArray(val)) {
key = key + '[]';
}
if (utils.isArray(val)) {
key = key + '[]';
}
if (!utils.isArray(val)) {
val = [val];
}
if (!utils.isArray(val)) {
val = [val];
}
utils.forEach(val, function (v) {
if (utils.isDate(v)) {
v = v.toISOString();
}
else if (utils.isObject(v)) {
v = JSON.stringify(v);
}
parts.push(encode(key) + '=' + encode(v));
utils.forEach(val, function (v) {
if (utils.isDate(v)) {
v = v.toISOString();
}
else if (utils.isObject(v)) {
v = JSON.stringify(v);
}
parts.push(encode(key) + '=' + encode(v));
});
});
});
if (parts.length > 0) {
url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&');
serializedParams = parts.join('&');
}
if (serializedParams) {
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
}
return url;
};
/***/ },
/* 8 */
/* 7 */
/***/ function(module, exports, __webpack_require__) {

@@ -858,3 +798,3 @@

/***/ },
/* 9 */
/* 8 */
/***/ function(module, exports, __webpack_require__) {

@@ -884,3 +824,3 @@

/***/ },
/* 10 */
/* 9 */
/***/ function(module, exports, __webpack_require__) {

@@ -890,43 +830,108 @@

/**
* WARNING:
* This file makes references to objects that aren't safe in all environments.
* Please see lib/utils.isStandardBrowserEnv before including this file.
*/
var utils = __webpack_require__(3);
module.exports = {
write: function write(name, value, expires, path, domain, secure) {
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
module.exports = (
utils.isStandardBrowserEnv() ?
if (utils.isNumber(expires)) {
cookie.push('expires=' + new Date(expires).toGMTString());
}
// Standard browser envs have full support of the APIs needed to test
// whether the request URL is of the same origin as current location.
(function () {
var msie = /(msie|trident)/i.test(navigator.userAgent);
var urlParsingNode = document.createElement('a');
var originURL;
if (utils.isString(path)) {
cookie.push('path=' + path);
}
/**
* Parse a URL to discover it's components
*
* @param {String} url The URL to be parsed
* @returns {Object}
*/
function resolveURL(url) {
var href = url;
if (utils.isString(domain)) {
cookie.push('domain=' + domain);
}
if (msie) {
// IE needs attribute set twice to normalize properties
urlParsingNode.setAttribute('href', href);
href = urlParsingNode.href;
}
if (secure === true) {
cookie.push('secure');
urlParsingNode.setAttribute('href', href);
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
return {
href: urlParsingNode.href,
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
host: urlParsingNode.host,
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
hostname: urlParsingNode.hostname,
port: urlParsingNode.port,
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
urlParsingNode.pathname :
'/' + urlParsingNode.pathname
};
}
document.cookie = cookie.join('; ');
},
originURL = resolveURL(window.location.href);
read: function read(name) {
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
},
/**
* Determine if a URL shares the same origin as the current location
*
* @param {String} requestURL The URL to test
* @returns {boolean} True if URL shares the same origin, otherwise false
*/
return function isURLSameOrigin(requestURL) {
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
return (parsed.protocol === originURL.protocol &&
parsed.host === originURL.host);
};
})() :
remove: function remove(name) {
this.write(name, '', Date.now() - 86400000);
// Non standard browser envs (web workers, react-native) lack needed support.
(function () {
return function isURLSameOrigin() {
return true;
};
})()
);
/***/ },
/* 10 */
/***/ function(module, exports) {
'use strict';
// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
function InvalidCharacterError(message) {
this.message = message;
}
InvalidCharacterError.prototype = new Error;
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
function btoa (input) {
var str = String(input);
for (
// initialize result and counter
var block, charCode, idx = 0, map = chars, output = '';
// if the next str index does not exist:
// change the mapping table to "="
// check if d has no fractional digits
str.charAt(idx | 0) || (map = '=', idx % 1);
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
) {
charCode = str.charCodeAt(idx += 3/4);
if (charCode > 0xFF) {
throw new InvalidCharacterError('\'btoa\' failed: The string to be encoded contains characters outside of the Latin1 range.');
}
block = block << 8 | charCode;
}
return output;
};
module.exports = btoa

@@ -940,58 +945,53 @@

/**
* WARNING:
* This file makes references to objects that aren't safe in all environments.
* Please see lib/utils.isStandardBrowserEnv before including this file.
*/
var utils = __webpack_require__(3);
var msie = /(msie|trident)/i.test(navigator.userAgent);
var urlParsingNode = document.createElement('a');
var originUrl;
/**
* Parse a URL to discover it's components
*
* @param {String} url The URL to be parsed
* @returns {Object}
*/
function urlResolve(url) {
var href = url;
module.exports = (
utils.isStandardBrowserEnv() ?
if (msie) {
// IE needs attribute set twice to normalize properties
urlParsingNode.setAttribute('href', href);
href = urlParsingNode.href;
}
// Standard browser envs support document.cookie
(function () {
return {
write: function write(name, value, expires, path, domain, secure) {
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
urlParsingNode.setAttribute('href', href);
if (utils.isNumber(expires)) {
cookie.push('expires=' + new Date(expires).toGMTString());
}
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
return {
href: urlParsingNode.href,
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
host: urlParsingNode.host,
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
hostname: urlParsingNode.hostname,
port: urlParsingNode.port,
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
urlParsingNode.pathname :
'/' + urlParsingNode.pathname
};
}
if (utils.isString(path)) {
cookie.push('path=' + path);
}
originUrl = urlResolve(window.location.href);
if (utils.isString(domain)) {
cookie.push('domain=' + domain);
}
/**
* Determine if a URL shares the same origin as the current location
*
* @param {String} requestUrl The URL to test
* @returns {boolean} True if URL shares the same origin, otherwise false
*/
module.exports = function urlIsSameOrigin(requestUrl) {
var parsed = (utils.isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl;
return (parsed.protocol === originUrl.protocol &&
parsed.host === originUrl.host);
};
if (secure === true) {
cookie.push('secure');
}
document.cookie = cookie.join('; ');
},
read: function read(name) {
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
},
remove: function remove(name) {
this.write(name, '', Date.now() - 86400000);
}
};
})() :
// Non standard browser env (web workers, react-native) lack needed support.
(function () {
return {
write: function write() {},
read: function read() { return null; },
remove: function remove() {}
};
})()
);

@@ -1064,2 +1064,40 @@

/**
* Determines whether the specified URL is absolute
*
* @param {string} url The URL to test
* @returns {boolean} True if the specified URL is absolute, otherwise false
*/
module.exports = function isAbsoluteURL(url) {
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
// by any combination of letters, digits, plus, period, or hyphen.
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
};
/***/ },
/* 14 */
/***/ function(module, exports) {
'use strict';
/**
* Creates a new URL by combining the specified URLs
*
* @param {string} baseURL The base URL
* @param {string} relativeURL The relative URL
* @returns {string} The combined URL
*/
module.exports = function combineURLs(baseURL, relativeURL) {
return baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '');
};
/***/ },
/* 15 */
/***/ function(module, exports) {
'use strict';
/**
* Syntactic sugar for invoking a function and expanding an array for arguments.

@@ -1066,0 +1104,0 @@ *

@@ -1,3 +0,3 @@

/* axios v0.7.0 | (c) 2015 by Matt Zabriskie */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";var r=n(2),o=n(3),i=n(4),s=n(12),u=e.exports=function(e){"string"==typeof e&&(e=o.merge({url:arguments[0]},arguments[1])),e=o.merge({method:"get",headers:{},timeout:r.timeout,transformRequest:r.transformRequest,transformResponse:r.transformResponse},e),e.withCredentials=e.withCredentials||r.withCredentials;var t=[i,void 0],n=Promise.resolve(e);for(u.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),u.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n};u.defaults=r,u.all=function(e){return Promise.all(e)},u.spread=n(13),u.interceptors={request:new s,response:new s},function(){function e(){o.forEach(arguments,function(e){u[e]=function(t,n){return u(o.merge(n||{},{method:e,url:t}))}})}function t(){o.forEach(arguments,function(e){u[e]=function(t,n,r){return u(o.merge(r||{},{method:e,url:t,data:n}))}})}e("delete","get","head"),t("post","put","patch")}()},function(e,t,n){"use strict";var r=n(3),o=/^\)\]\}',?\n/,i={"Content-Type":"application/x-www-form-urlencoded"};e.exports={transformRequest:[function(e,t){return r.isFormData(e)?e:r.isArrayBuffer(e)?e:r.isArrayBufferView(e)?e.buffer:!r.isObject(e)||r.isFile(e)||r.isBlob(e)?e:(r.isUndefined(t)||(r.forEach(t,function(e,n){"content-type"===n.toLowerCase()&&(t["Content-Type"]=e)}),r.isUndefined(t["Content-Type"])&&(t["Content-Type"]="application/json;charset=utf-8")),JSON.stringify(e))}],transformResponse:[function(e){if("string"==typeof e){e=e.replace(o,"");try{e=JSON.parse(e)}catch(t){}}return e}],headers:{common:{Accept:"application/json, text/plain, */*"},patch:r.merge(i),post:r.merge(i),put:r.merge(i)},timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"}},function(e,t){"use strict";function n(e){return"[object Array]"===v.call(e)}function r(e){return"[object ArrayBuffer]"===v.call(e)}function o(e){return"[object FormData]"===v.call(e)}function i(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function s(e){return"string"==typeof e}function u(e){return"number"==typeof e}function a(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function c(e){return"[object Date]"===v.call(e)}function p(e){return"[object File]"===v.call(e)}function l(e){return"[object Blob]"===v.call(e)}function d(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function h(e){return"[object Arguments]"===v.call(e)}function m(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function y(e,t){if(null!==e&&"undefined"!=typeof e){var r=n(e)||h(e);if("object"==typeof e||r||(e=[e]),r)for(var o=0,i=e.length;i>o;o++)t.call(null,e[o],o,e);else for(var s in e)e.hasOwnProperty(s)&&t.call(null,e[s],s,e)}}function g(){var e={};return y(arguments,function(t){y(t,function(t,n){e[n]=t})}),e}var v=Object.prototype.toString;e.exports={isArray:n,isArrayBuffer:r,isFormData:o,isArrayBufferView:i,isString:s,isNumber:u,isObject:f,isUndefined:a,isDate:c,isFile:p,isBlob:l,isStandardBrowserEnv:m,forEach:y,merge:g,trim:d}},function(e,t,n){(function(t){"use strict";e.exports=function(e){return new Promise(function(r,o){try{"undefined"!=typeof XMLHttpRequest||"undefined"!=typeof ActiveXObject?n(6)(r,o,e):"undefined"!=typeof t&&n(6)(r,o,e)}catch(i){o(i)}})}}).call(t,n(5))},function(e,t){function n(){f=!1,s.length?a=s.concat(a):c=-1,a.length&&r()}function r(){if(!f){var e=setTimeout(n);f=!0;for(var t=a.length;t;){for(s=a,a=[];++c<t;)s&&s[c].run();c=-1,t=a.length}s=null,f=!1,clearTimeout(e)}}function o(e,t){this.fun=e,this.array=t}function i(){}var s,u=e.exports={},a=[],f=!1,c=-1;u.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];a.push(new o(e,t)),1!==a.length||f||setTimeout(r,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},u.title="browser",u.browser=!0,u.env={},u.argv=[],u.version="",u.versions={},u.on=i,u.addListener=i,u.once=i,u.off=i,u.removeListener=i,u.removeAllListeners=i,u.emit=i,u.binding=function(e){throw new Error("process.binding is not supported")},u.cwd=function(){return"/"},u.chdir=function(e){throw new Error("process.chdir is not supported")},u.umask=function(){return 0}},function(e,t,n){"use strict";var r=n(2),o=n(3),i=n(7),s=n(8),u=n(9);e.exports=function(e,t,a){var f=u(a.data,a.headers,a.transformRequest),c=o.merge(r.headers.common,r.headers[a.method]||{},a.headers||{});o.isFormData(f)&&delete c["Content-Type"];var p=new(XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP");if(p.open(a.method.toUpperCase(),i(a.url,a.params),!0),p.timeout=a.timeout,p.onreadystatechange=function(){if(p&&4===p.readyState){var n=s(p.getAllResponseHeaders()),r=-1!==["text",""].indexOf(a.responseType||"")?p.responseText:p.response,o={data:u(r,n,a.transformResponse),status:p.status,statusText:p.statusText,headers:n,config:a};(p.status>=200&&p.status<300?e:t)(o),p=null}},o.isStandardBrowserEnv()){var l=n(10),d=n(11),h=d(a.url)?l.read(a.xsrfCookieName||r.xsrfCookieName):void 0;h&&(c[a.xsrfHeaderName||r.xsrfHeaderName]=h)}if(o.forEach(c,function(e,t){f||"content-type"!==t.toLowerCase()?p.setRequestHeader(t,e):delete c[t]}),a.withCredentials&&(p.withCredentials=!0),a.responseType)try{p.responseType=a.responseType}catch(m){if("json"!==p.responseType)throw m}o.isArrayBuffer(f)&&(f=new DataView(f)),p.send(f)}},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(3);e.exports=function(e,t){if(!t)return e;var n=[];return o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)&&(t+="[]"),o.isArray(e)||(e=[e]),o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),n.push(r(t)+"="+r(e))}))}),n.length>0&&(e+=(-1===e.indexOf("?")?"?":"&")+n.join("&")),e}},function(e,t,n){"use strict";var r=n(3);e.exports=function(e){var t,n,o,i={};return e?(r.forEach(e.split("\n"),function(e){o=e.indexOf(":"),t=r.trim(e.substr(0,o)).toLowerCase(),n=r.trim(e.substr(o+1)),t&&(i[t]=i[t]?i[t]+", "+n:n)}),i):i}},function(e,t,n){"use strict";var r=n(3);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t,n){"use strict";var r=n(3);e.exports={write:function(e,t,n,o,i,s){var u=[];u.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&u.push("expires="+new Date(n).toGMTString()),r.isString(o)&&u.push("path="+o),r.isString(i)&&u.push("domain="+i),s===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}},function(e,t,n){"use strict";function r(e){var t=e;return s&&(u.setAttribute("href",t),t=u.href),u.setAttribute("href",t),{href:u.href,protocol:u.protocol?u.protocol.replace(/:$/,""):"",host:u.host,search:u.search?u.search.replace(/^\?/,""):"",hash:u.hash?u.hash.replace(/^#/,""):"",hostname:u.hostname,port:u.port,pathname:"/"===u.pathname.charAt(0)?u.pathname:"/"+u.pathname}}var o,i=n(3),s=/(msie|trident)/i.test(navigator.userAgent),u=document.createElement("a");o=r(window.location.href),e.exports=function(e){var t=i.isString(e)?r(e):e;return t.protocol===o.protocol&&t.host===o.host}},function(e,t,n){"use strict";function r(){this.handlers=[]}var o=n(3);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])});
/* axios v0.8.0 | (c) 2015 by Matt Zabriskie */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";function n(e){this.defaultConfig=s.merge({headers:{},timeout:i.timeout,transformRequest:i.transformRequest,transformResponse:i.transformResponse},e),this.interceptors={request:new a,response:new a}}function o(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}}var i=r(2),s=r(3),u=r(4),a=r(12),c=r(13),f=r(14);n.prototype.request=function(e){"string"==typeof e&&(e=s.merge({url:arguments[0]},arguments[1])),e=s.merge(this.defaultConfig,{method:"get"},e),e.baseURL&&!c(e.url)&&(e.url=f(e.baseURL,e.url)),e.withCredentials=e.withCredentials||i.withCredentials;var t=[u,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)r=r.then(t.shift(),t.shift());return r};var p=new n,l=e.exports=o(n.prototype.request,p);l.create=function(e){return new n(e)},l.defaults=i,l.all=function(e){return Promise.all(e)},l.spread=r(15),l.interceptors=p.interceptors,s.forEach(["delete","get","head"],function(e){n.prototype[e]=function(t,r){return this.request(s.merge(r||{},{method:e,url:t}))},l[e]=o(n.prototype[e],p)}),s.forEach(["post","put","patch"],function(e){n.prototype[e]=function(t,r,n){return this.request(s.merge(n||{},{method:e,url:t,data:r}))},l[e]=o(n.prototype[e],p)})},function(e,t,r){"use strict";var n=r(3),o=/^\)\]\}',?\n/,i={"Content-Type":"application/x-www-form-urlencoded"};e.exports={transformRequest:[function(e,t){return n.isFormData(e)?e:n.isArrayBuffer(e)?e:n.isArrayBufferView(e)?e.buffer:!n.isObject(e)||n.isFile(e)||n.isBlob(e)?e:(n.isUndefined(t)||(n.forEach(t,function(e,r){"content-type"===r.toLowerCase()&&(t["Content-Type"]=e)}),n.isUndefined(t["Content-Type"])&&(t["Content-Type"]="application/json;charset=utf-8")),JSON.stringify(e))}],transformResponse:[function(e){if("string"==typeof e){e=e.replace(o,"");try{e=JSON.parse(e)}catch(t){}}return e}],headers:{common:{Accept:"application/json, text/plain, */*"},patch:n.merge(i),post:n.merge(i),put:n.merge(i)},timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"}},function(e,t){"use strict";function r(e){return"[object Array]"===g.call(e)}function n(e){return"[object ArrayBuffer]"===g.call(e)}function o(e){return"[object FormData]"===g.call(e)}function i(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function s(e){return"string"==typeof e}function u(e){return"number"==typeof e}function a(e){return"undefined"==typeof e}function c(e){return null!==e&&"object"==typeof e}function f(e){return"[object Date]"===g.call(e)}function p(e){return"[object File]"===g.call(e)}function l(e){return"[object Blob]"===g.call(e)}function d(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function h(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function m(e,t){if(null!==e&&"undefined"!=typeof e)if("object"==typeof e||r(e)||(e=[e]),r(e))for(var n=0,o=e.length;o>n;n++)t.call(null,e[n],n,e);else for(var i in e)e.hasOwnProperty(i)&&t.call(null,e[i],i,e)}function y(){for(var e={},t=function(t,r){e[r]=t},r=arguments.length,n=0;r>n;n++)m(arguments[n],t);return e}var g=Object.prototype.toString;e.exports={isArray:r,isArrayBuffer:n,isFormData:o,isArrayBufferView:i,isString:s,isNumber:u,isObject:c,isUndefined:a,isDate:f,isFile:p,isBlob:l,isStandardBrowserEnv:h,forEach:m,merge:y,trim:d}},function(e,t,r){"use strict";e.exports=function(e){return new Promise(function(t,n){try{"undefined"!=typeof XMLHttpRequest||"undefined"!=typeof ActiveXObject?r(5)(t,n,e):"undefined"!=typeof process&&r(5)(t,n,e)}catch(o){n(o)}})}},function(e,t,r){"use strict";var n=r(2),o=r(3),i=r(6),s=r(7),u=r(8),a=r(9),c=window.btoa||r(10);e.exports=function(e,t,f){var p=u(f.data,f.headers,f.transformRequest),l=o.merge(n.headers.common,n.headers[f.method]||{},f.headers||{});o.isFormData(p)&&delete l["Content-Type"];var d=XMLHttpRequest||ActiveXObject,h="onreadystatechange",m=!1;if(!a(f.url)&&window.XDomainRequest&&(d=window.XDomainRequest,h="onload",m=!0),f.auth){var y=f.auth.username||"",g=f.auth.password||"";l.Authorization="Basic: "+c(y+":"+g)}var w=new d("Microsoft.XMLHTTP");if(w.open(f.method.toUpperCase(),i(f.url,f.params,f.paramsSerializer),!0),w.timeout=f.timeout,w[h]=function(){if(w&&(4===w.readyState||m)){var r=m?null:s(w.getAllResponseHeaders()),n=-1!==["text",""].indexOf(f.responseType||"")?w.responseText:w.response,o={data:u(n,r,f.transformResponse),status:w.status,statusText:w.statusText,headers:r,config:f};(w.status>=200&&w.status<300||w.responseText&&m?e:t)(o),w=null}},o.isStandardBrowserEnv()){var v=r(11),x=a(f.url)?v.read(f.xsrfCookieName||n.xsrfCookieName):void 0;x&&(l[f.xsrfHeaderName||n.xsrfHeaderName]=x)}if(m||o.forEach(l,function(e,t){p||"content-type"!==t.toLowerCase()?w.setRequestHeader(t,e):delete l[t]}),f.withCredentials&&(w.withCredentials=!0),f.responseType)try{w.responseType=f.responseType}catch(b){if("json"!==w.responseType)throw b}o.isArrayBuffer(p)&&(p=new DataView(p)),w.send(p)}},function(e,t,r){"use strict";function n(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=r(3);e.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else{var s=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)&&(t+="[]"),o.isArray(e)||(e=[e]),o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),s.push(n(t)+"="+n(e))}))}),i=s.join("&")}return i&&(e+=(-1===e.indexOf("?")?"?":"&")+i),e}},function(e,t,r){"use strict";var n=r(3);e.exports=function(e){var t,r,o,i={};return e?(n.forEach(e.split("\n"),function(e){o=e.indexOf(":"),t=n.trim(e.substr(0,o)).toLowerCase(),r=n.trim(e.substr(o+1)),t&&(i[t]=i[t]?i[t]+", "+r:r)}),i):i}},function(e,t,r){"use strict";var n=r(3);e.exports=function(e,t,r){return n.forEach(r,function(r){e=r(e,t)}),e}},function(e,t,r){"use strict";var n=r(3);e.exports=n.isStandardBrowserEnv()?function(){function e(e){var t=e;return r&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,r=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(r){var o=n.isString(r)?e(r):r;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t){"use strict";function r(e){this.message=e}function n(e){for(var t,n,i=String(e),s=0,u=o,a="";i.charAt(0|s)||(u="=",s%1);a+=u.charAt(63&t>>8-s%1*8)){if(n=i.charCodeAt(s+=.75),n>255)throw new r("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");t=t<<8|n}return a}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.prototype=new Error,r.prototype.name="InvalidCharacterError",e.exports=n},function(e,t,r){"use strict";var n=r(3);e.exports=n.isStandardBrowserEnv()?function(){return{write:function(e,t,r,o,i,s){var u=[];u.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),n.isString(o)&&u.push("path="+o),n.isString(i)&&u.push("domain="+i),s===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,r){"use strict";function n(){this.handlers=[]}var o=r(3);n.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},n.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},n.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=n},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,"")}},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])});
//# sourceMappingURL=axios.min.map

@@ -5,7 +5,8 @@ 'use strict';

var utils = require('./../utils');
var buildUrl = require('./../helpers/buildUrl');
var buildURL = require('./../helpers/buildURL');
var transformData = require('./../helpers/transformData');
var http = require('http');
var https = require('https');
var http = require('follow-redirects').http;
var https = require('follow-redirects').https;
var url = require('url');
var zlib = require('zlib');
var pkg = require('./../../package.json');

@@ -49,2 +50,10 @@ var Buffer = require('buffer').Buffer;

// HTTP basic authentication
var auth = undefined;
if (config.auth) {
var username = config.auth.username || '';
var password = config.auth.password || '';
auth = username + ':' + password;
}
// Parse url

@@ -55,6 +64,7 @@ var parsed = url.parse(config.url);

port: parsed.port,
path: buildUrl(parsed.path, config.params).replace(/^\?/, ''),
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
method: config.method,
headers: headers,
agent: config.agent
agent: config.agent,
auth: auth
};

@@ -65,11 +75,30 @@

var req = transport.request(options, function (res) {
// uncompress the response body transparently if required
var stream = res;
switch(res.headers['content-encoding']) {
case 'gzip':
case 'compress':
case 'deflate': {
// add the unzipper to the body stream processing pipeline
stream = stream.pipe(zlib.createUnzip());
// remove the content-encoding in order to not confuse downstream operations
delete res.headers['content-encoding'];
}
}
var responseBuffer = [];
res.on('data', function (chunk) {
stream.on('data', function (chunk) {
responseBuffer.push(chunk);
});
res.on('end', function () {
stream.on('end', function () {
var data = Buffer.concat(responseBuffer);
if (config.responseType !== 'arraybuffer') {
data = data.toString('utf8');
}
var response = {
data: transformData(
Buffer.concat(responseBuffer).toString('utf8'),
data,
res.headers,

@@ -76,0 +105,0 @@ config.transformResponse

@@ -7,5 +7,7 @@ 'use strict';

var utils = require('./../utils');
var buildUrl = require('./../helpers/buildUrl');
var buildURL = require('./../helpers/buildURL');
var parseHeaders = require('./../helpers/parseHeaders');
var transformData = require('./../helpers/transformData');
var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
var btoa = window.btoa || require('./../helpers/btoa.js')

@@ -31,5 +33,23 @@ module.exports = function xhrAdapter(resolve, reject, config) {

var adapter = (XMLHttpRequest || ActiveXObject);
var loadEvent = 'onreadystatechange';
var xDomain = false;
// For IE 8/9 CORS support
if(!isURLSameOrigin(config.url) && window.XDomainRequest){
adapter = window.XDomainRequest;
loadEvent = 'onload';
xDomain = true;
}
// HTTP basic authentication
if (config.auth) {
var username = config.auth.username || '';
var password = config.auth.password || '';
requestHeaders['Authorization'] = 'Basic: ' + btoa(username + ':' + password);
}
// Create the request
var request = new (XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
request.open(config.method.toUpperCase(), buildUrl(config.url, config.params), true);
var request = new adapter('Microsoft.XMLHTTP');
request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);

@@ -40,6 +60,6 @@ // Set the request timeout in MS

// Listen for ready state
request.onreadystatechange = function () {
if (request && request.readyState === 4) {
request[loadEvent] = function () {
if (request && (request.readyState === 4 || xDomain)) {
// Prepare the response
var responseHeaders = parseHeaders(request.getAllResponseHeaders());
var responseHeaders = xDomain ? null : parseHeaders(request.getAllResponseHeaders());
var responseData = ['text', ''].indexOf(config.responseType || '') !== -1 ? request.responseText : request.response;

@@ -57,5 +77,4 @@ var response = {

};
// Resolve or reject the Promise based on the status
(request.status >= 200 && request.status < 300 ?
((request.status >= 200 && request.status < 300) || (request.responseText && xDomain) ?
resolve :

@@ -74,6 +93,5 @@ reject)(response);

var cookies = require('./../helpers/cookies');
var urlIsSameOrigin = require('./../helpers/urlIsSameOrigin');
// Add xsrf header
var xsrfValue = urlIsSameOrigin(config.url) ?
var xsrfValue = isURLSameOrigin(config.url) ?
cookies.read(config.xsrfCookieName || defaults.xsrfCookieName) :

@@ -88,12 +106,13 @@ undefined;

// Add headers to the request
utils.forEach(requestHeaders, function (val, key) {
// Remove Content-Type if data is undefined
if (!data && key.toLowerCase() === 'content-type') {
delete requestHeaders[key];
}
// Otherwise add header to the request
else {
request.setRequestHeader(key, val);
}
});
if(!xDomain)
utils.forEach(requestHeaders, function (val, key) {
// Remove Content-Type if data is undefined
if (!data && key.toLowerCase() === 'content-type') {
delete requestHeaders[key];
}
// Otherwise add header to the request
else {
request.setRequestHeader(key, val);
}
});

@@ -100,0 +119,0 @@ // Add withCredentials to request if needed

@@ -7,4 +7,20 @@ 'use strict';

var InterceptorManager = require('./core/InterceptorManager');
var isAbsoluteURL = require('./helpers/isAbsoluteURL');
var combineURLs = require('./helpers/combineURLs');
var axios = module.exports = function (config) {
function Axios (defaultConfig) {
this.defaultConfig = utils.merge({
headers: {},
timeout: defaults.timeout,
transformRequest: defaults.transformRequest,
transformResponse: defaults.transformResponse
}, defaultConfig);
this.interceptors = {
request: new InterceptorManager(),
response: new InterceptorManager()
};
}
Axios.prototype.request = function (config) {
// Allow for axios('example/url'[, config]) a la fetch API

@@ -17,10 +33,8 @@ if (typeof config === 'string') {

config = utils.merge({
method: 'get',
headers: {},
timeout: defaults.timeout,
transformRequest: defaults.transformRequest,
transformResponse: defaults.transformResponse
}, config);
config = utils.merge(this.defaultConfig, { method: 'get' }, config);
if (config.baseURL && !isAbsoluteURL(config.url)) {
config.url = combineURLs(config.baseURL, config.url);
}
// Don't allow overriding defaults.withCredentials

@@ -33,7 +47,7 @@ config.withCredentials = config.withCredentials || defaults.withCredentials;

axios.interceptors.request.forEach(function (interceptor) {
this.interceptors.request.forEach(function (interceptor) {
chain.unshift(interceptor.fulfilled, interceptor.rejected);
});
axios.interceptors.response.forEach(function (interceptor) {
this.interceptors.response.forEach(function (interceptor) {
chain.push(interceptor.fulfilled, interceptor.rejected);

@@ -49,2 +63,10 @@ });

var defaultInstance = new Axios();
var axios = module.exports = bind(Axios.prototype.request, defaultInstance);
axios.create = function (defaultConfig) {
return new Axios(defaultConfig);
};
// Expose defaults

@@ -60,34 +82,35 @@ axios.defaults = defaults;

// Expose interceptors
axios.interceptors = {
request: new InterceptorManager(),
response: new InterceptorManager()
};
axios.interceptors = defaultInstance.interceptors;
// Helpers
function bind (fn, thisArg) {
return function () {
var args = new Array(arguments.length);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i];
}
return fn.apply(thisArg, args);
};
}
// Provide aliases for supported request methods
(function () {
function createShortMethods() {
utils.forEach(arguments, function (method) {
axios[method] = function (url, config) {
return axios(utils.merge(config || {}, {
method: method,
url: url
}));
};
});
}
utils.forEach(['delete', 'get', 'head'], function (method) {
Axios.prototype[method] = function (url, config) {
return this.request(utils.merge(config || {}, {
method: method,
url: url
}));
};
axios[method] = bind(Axios.prototype[method], defaultInstance);
});
function createShortMethodsWithData() {
utils.forEach(arguments, function (method) {
axios[method] = function (url, data, config) {
return axios(utils.merge(config || {}, {
method: method,
url: url,
data: data
}));
};
});
}
createShortMethods('delete', 'get', 'head');
createShortMethodsWithData('post', 'put', 'patch');
})();
utils.forEach(['post', 'put', 'patch'], function (method) {
Axios.prototype[method] = function (url, data, config) {
return this.request(utils.merge(config || {}, {
method: method,
url: url,
data: data
}));
};
axios[method] = bind(Axios.prototype[method], defaultInstance);
});
'use strict';
/**
* WARNING:
* This file makes references to objects that aren't safe in all environments.
* Please see lib/utils.isStandardBrowserEnv before including this file.
*/
var utils = require('./../utils');
module.exports = {
write: function write(name, value, expires, path, domain, secure) {
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
module.exports = (
utils.isStandardBrowserEnv() ?
if (utils.isNumber(expires)) {
cookie.push('expires=' + new Date(expires).toGMTString());
}
// Standard browser envs support document.cookie
(function () {
return {
write: function write(name, value, expires, path, domain, secure) {
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
if (utils.isString(path)) {
cookie.push('path=' + path);
}
if (utils.isNumber(expires)) {
cookie.push('expires=' + new Date(expires).toGMTString());
}
if (utils.isString(domain)) {
cookie.push('domain=' + domain);
}
if (utils.isString(path)) {
cookie.push('path=' + path);
}
if (secure === true) {
cookie.push('secure');
}
if (utils.isString(domain)) {
cookie.push('domain=' + domain);
}
document.cookie = cookie.join('; ');
},
if (secure === true) {
cookie.push('secure');
}
read: function read(name) {
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
},
document.cookie = cookie.join('; ');
},
remove: function remove(name) {
this.write(name, '', Date.now() - 86400000);
}
};
read: function read(name) {
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
},
remove: function remove(name) {
this.write(name, '', Date.now() - 86400000);
}
};
})() :
// Non standard browser env (web workers, react-native) lack needed support.
(function () {
return {
write: function write() {},
read: function read() { return null; },
remove: function remove() {}
};
})()
);

@@ -134,12 +134,2 @@ 'use strict';

/**
* Determine if a value is an Arguments object
*
* @param {Object} val The value to test
* @returns {boolean} True if value is an Arguments object, otherwise false
*/
function isArguments(val) {
return toString.call(val) === '[object Arguments]';
}
/**
* Determine if we're running in a standard browser environment

@@ -155,3 +145,3 @@ *

* react-native:
* typeof document.createelement -> undefined
* typeof document.createElement -> undefined
*/

@@ -169,3 +159,3 @@ function isStandardBrowserEnv() {

*
* If `obj` is an Array or arguments callback will be called passing
* If `obj` is an Array callback will be called passing
* the value, index, and complete array for each item.

@@ -185,7 +175,4 @@ *

// Check if obj is array-like
var isArrayLike = isArray(obj) || isArguments(obj);
// Force an array if not already something iterable
if (typeof obj !== 'object' && !isArrayLike) {
if (typeof obj !== 'object' && !isArray(obj)) {
obj = [obj];

@@ -195,3 +182,3 @@ }

// Iterate over array values
if (isArrayLike) {
if (isArray(obj)) {
for (var i = 0, l = obj.length; i < l; i++) {

@@ -230,7 +217,7 @@ fn.call(null, obj[i], i, obj);

var result = {};
forEach(arguments, function (obj) {
forEach(obj, function (val, key) {
result[key] = val;
});
});
var assignValue = function (val, key) { result[key] = val; };
var length = arguments.length;
for (var i = 0; i < length; i++) {
forEach(arguments[i], assignValue);
}
return result;

@@ -237,0 +224,0 @@ }

{
"name": "axios",
"version": "0.7.0",
"version": "0.8.0",
"description": "Promise based HTTP client for the browser and node.js",
"main": "index.js",
"scripts": {
"test": "grunt test",
"build": "./node_modules/.bin/grunt build",
"test": "./node_modules/.bin/grunt test",
"start": "node ./sandbox/server.js",

@@ -43,2 +44,3 @@ "examples": "node ./examples/server.js",

"grunt-webpack": "1.0.11",
"istanbul-instrumenter-loader": "^0.1.3",
"jasmine-core": "2.3.4",

@@ -50,2 +52,3 @@ "karma": "0.13.10",

"karma-phantomjs-launcher": "0.2.1",
"karma-sinon": "1.0.4",
"karma-sourcemap-loader": "0.3.5",

@@ -64,3 +67,6 @@ "karma-webpack": "1.7.0",

"definition": "./axios.d.ts"
},
"dependencies": {
"follow-redirects": "0.0.7"
}
}

@@ -54,3 +54,3 @@ # axios

});
// Optionally the request above could also be done as

@@ -136,5 +136,31 @@ axios.get('/user', {

### Creating an instance
You can create a new instance of axios with a custom config.
##### axios.create([config])
```js
var instance = axios.create({
baseURL: 'https://some-domain.com/api/',
timeout: 1000,
headers: {'X-Custom-Header': 'foobar'}
});
```
### Instance methods
The available instance methods are listed below. The specified config will be merged with the instance config.
##### axios#request(config)
##### axios#get(url[, config])
##### axios#delete(url[, config])
##### axios#head(url[, config])
##### axios#post(url[, data[, config]])
##### axios#put(url[, data[, config]])
##### axios#patch(url[, data[, config]])
## Request API
This is the available config options for making requests. Only the `url` is required. Requests will default to `GET` if `method` is not specified.
These are the available config options for making requests. Only the `url` is required. Requests will default to `GET` if `method` is not specified.

@@ -145,2 +171,7 @@ ```js

url: '/user',
// `baseURL` will be prepended to `url` unless `url` is absolute.
// It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
// to methods of that instance.
baseURL: 'https://some-domain.com/api/',

@@ -155,3 +186,3 @@ // `method` is the request method to be used when making the request

// Do whatever you want to transform the data
return data;

@@ -164,3 +195,3 @@ }],

// Do whatever you want to transform the data
return data;

@@ -177,2 +208,8 @@ }],

// `paramsSerializer` is an optional function in charge of serializing `params`
// (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)
paramsSerializer: function(params) {
return Qs.stringify(params, {arrayFormat: 'brackets'})
},
// `data` is the data to be sent as the request body

@@ -193,2 +230,10 @@ // Only applicable for request methods 'PUT', 'POST', and 'PATCH'

// `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
// This will set an `Authorization` header, overwriting any existing
// `Authorization` custom headers you have set using `headers`.
auth: {
username: 'janedoe',
password: 's00pers3cret'
}
// `responseType` indicates the type of data that the server will respond with

@@ -217,3 +262,3 @@ // options are 'arraybuffer', 'blob', 'document', 'json', 'text'

status: 200,
// `statusText` is the HTTP status message from the server response

@@ -274,2 +319,9 @@ statusText: 'OK',

You can add interceptors to a custom instance of axios.
```js
var instance = axios.create();
instance.interceptors.request.use(function () {/*...*/});
```
## Handling Errors

@@ -276,0 +328,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc