Socket
Socket
Sign inDemoInstall

axios

Package Overview
Dependencies
0
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.0 to 0.7.0

UPGRADE_GUIDE.md

6

axios.d.ts

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

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

@@ -29,4 +29,4 @@

interface Promise {
then(response: axios.Response): axios.Promise;
catch(response: axios.Response): axios.Promise;
then(onFulfilled:(response: axios.Response) => void): axios.Promise;
catch(onRejected:(response: axios.Response) => void): axios.Promise;
}

@@ -33,0 +33,0 @@

@@ -82,1 +82,11 @@ # Changelog

- Converting build to UMD
### 0.7.0 (Sep 29, 2015)
- Fixing issue with minified bundle in IE8 ([#87](https://github.com/mzabriskie/axios/pull/87))
- Adding support for passing agent in node ([#102](https://github.com/mzabriskie/axios/pull/102))
- Adding support for returning result from `axios.spread` for chaining ([#106](https://github.com/mzabriskie/axios/pull/106))
- Fixing typescript definition ([#105](https://github.com/mzabriskie/axios/pull/105))
- Fixing default timeout config for node ([#112](https://github.com/mzabriskie/axios/pull/112))
- Adding support for use in web workers, and react-native ([#70](https://github.com/mzabriskie/axios/issue/70)), ([#98](https://github.com/mzabriskie/axios/pull/98))
- Adding support for fetch like API `axios(url[, config])` ([#116](https://github.com/mzabriskie/axios/issues/116))

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

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

@@ -70,6 +71,14 @@ if(typeof exports === 'object' && typeof module === 'object')

var axios = module.exports = function axios(config) {
var axios = module.exports = function (config) {
// Allow for axios('example/url'[, config]) a la fetch API
if (typeof config === 'string') {
config = utils.merge({
url: arguments[0]
}, arguments[1]);
}
config = utils.merge({
method: 'get',
headers: {},
timeout: defaults.timeout,
transformRequest: defaults.transformRequest,

@@ -361,2 +370,23 @@ transformResponse: defaults.transformResponse

/**
* Determine if we're running in a standard browser environment
*
* This allows axios to run in a web worker, and react-native.
* Both environments support XMLHttpRequest, but not fully standard globals.
*
* web workers:
* typeof window -> undefined
* typeof document -> undefined
*
* react-native:
* typeof document.createelement -> undefined
*/
function isStandardBrowserEnv() {
return (
typeof window !== 'undefined' &&
typeof document !== 'undefined' &&
typeof document.createElement === 'function'
);
}
/**
* Iterate over an Array or an Object invoking a function for each item.

@@ -442,2 +472,3 @@ *

isBlob: isBlob,
isStandardBrowserEnv: isStandardBrowserEnv,
forEach: forEach,

@@ -590,6 +621,4 @@ merge: merge,

var buildUrl = __webpack_require__(7);
var cookies = __webpack_require__(8);
var parseHeaders = __webpack_require__(9);
var transformData = __webpack_require__(10);
var urlIsSameOrigin = __webpack_require__(11);
var parseHeaders = __webpack_require__(8);
var transformData = __webpack_require__(9);

@@ -651,7 +680,16 @@ module.exports = function xhrAdapter(resolve, reject, config) {

// Add xsrf header
var xsrfValue = urlIsSameOrigin(config.url) ?
cookies.read(config.xsrfCookieName || defaults.xsrfCookieName) :
undefined;
if (xsrfValue) {
requestHeaders[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
// This is only done if running in a standard browser environment.
// Specifically not if we're in a web worker, or react-native.
if (utils.isStandardBrowserEnv()) {
var cookies = __webpack_require__(10);
var urlIsSameOrigin = __webpack_require__(11);
// Add xsrf header
var xsrfValue = urlIsSameOrigin(config.url) ?
cookies.read(config.xsrfCookieName || defaults.xsrfCookieName) :
undefined;
if (xsrfValue) {
requestHeaders[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
}
}

@@ -769,45 +807,2 @@

module.exports = {
write: function write(name, value, expires, path, domain, secure) {
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
if (utils.isNumber(expires)) {
cookie.push('expires=' + new Date(expires).toGMTString());
}
if (utils.isString(path)) {
cookie.push('path=' + path);
}
if (utils.isString(domain)) {
cookie.push('domain=' + domain);
}
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);
}
};
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(3);
/**

@@ -846,3 +841,3 @@ * Parse headers into an object

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

@@ -872,2 +867,51 @@

/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
'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 = __webpack_require__(3);
module.exports = {
write: function write(name, value, expires, path, domain, secure) {
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
if (utils.isNumber(expires)) {
cookie.push('expires=' + new Date(expires).toGMTString());
}
if (utils.isString(path)) {
cookie.push('path=' + path);
}
if (utils.isString(domain)) {
cookie.push('domain=' + domain);
}
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);
}
};
/***/ },
/* 11 */

@@ -878,2 +922,8 @@ /***/ function(module, exports, __webpack_require__) {

/**
* 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);

@@ -1017,3 +1067,3 @@ var msie = /(msie|trident)/i.test(navigator.userAgent);

return function (arr) {
callback.apply(null, arr);
return callback.apply(null, arr);
};

@@ -1020,0 +1070,0 @@ };

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

/* axios v0.6.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";var n=r(2),o=r(3),i=r(4),s=r(12),u=e.exports=function a(e){e=o.merge({method:"get",headers:{},transformRequest:n.transformRequest,transformResponse:n.transformResponse},e),e.withCredentials=e.withCredentials||n.withCredentials;var t=[i,void 0],r=Promise.resolve(e);for(a.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),a.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)r=r.then(t.shift(),t.shift());return r};u.defaults=n,u.all=function(e){return Promise.all(e)},u.spread=r(13),u.interceptors={request:new s,response:new s},function(){function e(){o.forEach(arguments,function(e){u[e]=function(t,r){return u(o.merge(r||{},{method:e,url:t}))}})}function t(){o.forEach(arguments,function(e){u[e]=function(t,r,n){return u(o.merge(n||{},{method:e,url:t,data:r}))}})}e("delete","get","head"),t("post","put","patch")}()},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 h(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function d(e){return"[object Arguments]"===g.call(e)}function m(e,t){if(null!==e&&"undefined"!=typeof e){var n=r(e)||d(e);if("object"==typeof e||n||(e=[e]),n)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 y(){var e={};return m(arguments,function(t){m(t,function(t,r){e[r]=t})}),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,forEach:m,merge:y,trim:h}},function(e,t,r){(function(t){"use strict";e.exports=function(e){return new Promise(function(n,o){try{"undefined"!=typeof XMLHttpRequest||"undefined"!=typeof ActiveXObject?r(6)(n,o,e):"undefined"!=typeof t&&r(6)(n,o,e)}catch(i){o(i)}})}}).call(t,r(5))},function(e,t){function r(){c=!1,s.length?a=s.concat(a):f=-1,a.length&&n()}function n(){if(!c){var e=setTimeout(r);c=!0;for(var t=a.length;t;){for(s=a,a=[];++f<t;)s&&s[f].run();f=-1,t=a.length}s=null,c=!1,clearTimeout(e)}}function o(e,t){this.fun=e,this.array=t}function i(){}var s,u=e.exports={},a=[],c=!1,f=-1;u.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];a.push(new o(e,t)),1!==a.length||c||setTimeout(n,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,r){"use strict";var n=r(2),o=r(3),i=r(7),s=r(8),u=r(9),a=r(10),c=r(11);e.exports=function(e,t,r){var f=a(r.data,r.headers,r.transformRequest),p=o.merge(n.headers.common,n.headers[r.method]||{},r.headers||{});o.isFormData(f)&&delete p["Content-Type"];var l=new(XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP");l.open(r.method.toUpperCase(),i(r.url,r.params),!0),l.timeout=r.timeout,l.onreadystatechange=function(){if(l&&4===l.readyState){var n=u(l.getAllResponseHeaders()),o=-1!==["text",""].indexOf(r.responseType||"")?l.responseText:l.response,i={data:a(o,n,r.transformResponse),status:l.status,statusText:l.statusText,headers:n,config:r};(l.status>=200&&l.status<300?e:t)(i),l=null}};var h=c(r.url)?s.read(r.xsrfCookieName||n.xsrfCookieName):void 0;if(h&&(p[r.xsrfHeaderName||n.xsrfHeaderName]=h),o.forEach(p,function(e,t){f||"content-type"!==t.toLowerCase()?l.setRequestHeader(t,e):delete p[t]}),r.withCredentials&&(l.withCredentials=!0),r.responseType)try{l.responseType=r.responseType}catch(d){if("json"!==l.responseType)throw d}o.isArrayBuffer(f)&&(f=new DataView(f)),l.send(f)}},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){if(!t)return e;var r=[];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)),r.push(n(t)+"="+n(e))}))}),r.length>0&&(e+=(-1===e.indexOf("?")?"?":"&")+r.join("&")),e}},function(e,t,r){"use strict";var n=r(3);e.exports={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(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";function n(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=r(3),s=/(msie|trident)/i.test(navigator.userAgent),u=document.createElement("a");o=n(window.location.href),e.exports=function(e){var t=i.isString(e)?n(e):e;return t.protocol===o.protocol&&t.host===o.host}},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 function(t){e.apply(null,t)}}}])});
/* 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)}}}])});
//# sourceMappingURL=axios.min.map

@@ -55,3 +55,4 @@ 'use strict';

method: config.method,
headers: headers
headers: headers,
agent: config.agent
};

@@ -58,0 +59,0 @@

@@ -8,6 +8,4 @@ 'use strict';

var buildUrl = require('./../helpers/buildUrl');
var cookies = require('./../helpers/cookies');
var parseHeaders = require('./../helpers/parseHeaders');
var transformData = require('./../helpers/transformData');
var urlIsSameOrigin = require('./../helpers/urlIsSameOrigin');

@@ -69,7 +67,16 @@ module.exports = function xhrAdapter(resolve, reject, config) {

// Add xsrf header
var xsrfValue = urlIsSameOrigin(config.url) ?
cookies.read(config.xsrfCookieName || defaults.xsrfCookieName) :
undefined;
if (xsrfValue) {
requestHeaders[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
// This is only done if running in a standard browser environment.
// Specifically not if we're in a web worker, or react-native.
if (utils.isStandardBrowserEnv()) {
var cookies = require('./../helpers/cookies');
var urlIsSameOrigin = require('./../helpers/urlIsSameOrigin');
// Add xsrf header
var xsrfValue = urlIsSameOrigin(config.url) ?
cookies.read(config.xsrfCookieName || defaults.xsrfCookieName) :
undefined;
if (xsrfValue) {
requestHeaders[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
}
}

@@ -76,0 +83,0 @@

@@ -8,6 +8,14 @@ 'use strict';

var axios = module.exports = function axios(config) {
var axios = module.exports = function (config) {
// Allow for axios('example/url'[, config]) a la fetch API
if (typeof config === 'string') {
config = utils.merge({
url: arguments[0]
}, arguments[1]);
}
config = utils.merge({
method: 'get',
headers: {},
timeout: defaults.timeout,
transformRequest: defaults.transformRequest,

@@ -14,0 +22,0 @@ transformResponse: defaults.transformResponse

'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');

@@ -4,0 +10,0 @@

@@ -25,4 +25,4 @@ 'use strict';

return function (arr) {
callback.apply(null, arr);
return callback.apply(null, arr);
};
};
'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');

@@ -4,0 +10,0 @@ var msie = /(msie|trident)/i.test(navigator.userAgent);

@@ -144,2 +144,23 @@ 'use strict';

/**
* Determine if we're running in a standard browser environment
*
* This allows axios to run in a web worker, and react-native.
* Both environments support XMLHttpRequest, but not fully standard globals.
*
* web workers:
* typeof window -> undefined
* typeof document -> undefined
*
* react-native:
* typeof document.createelement -> undefined
*/
function isStandardBrowserEnv() {
return (
typeof window !== 'undefined' &&
typeof document !== 'undefined' &&
typeof document.createElement === 'function'
);
}
/**
* Iterate over an Array or an Object invoking a function for each item.

@@ -225,2 +246,3 @@ *

isBlob: isBlob,
isStandardBrowserEnv: isStandardBrowserEnv,
forEach: forEach,

@@ -227,0 +249,0 @@ merge: merge,

{
"name": "axios",
"version": "0.6.0",
"version": "0.7.0",
"description": "Promise based HTTP client for the browser and node.js",

@@ -30,26 +30,28 @@ "main": "index.js",

"devDependencies": {
"coveralls": "^2.11.3",
"es6-promise": "^3.0.2",
"grunt": "^0.4.5",
"grunt-banner": "^0.5.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-nodeunit": "^0.4.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-eslint": "^17.1.0",
"grunt-karma": "^0.12.0",
"grunt-ts": "^5.0.0-beta.5",
"grunt-update-json": "^0.2.1",
"grunt-webpack": "^1.0.11",
"jasmine-core": "^2.3.4",
"karma": "^0.13.8",
"karma-coverage": "^0.5.0",
"karma-jasmine": "^0.3.6",
"karma-jasmine-ajax": "^0.1.12",
"karma-phantomjs-launcher": "^0.2.1",
"karma-sourcemap-loader": "^0.3.5",
"karma-webpack": "^1.7.0",
"load-grunt-tasks": "^3.2.0",
"minimist": "^1.1.3",
"webpack": "^1.11.0",
"webpack-dev-server": "^1.10.1"
"coveralls": "2.11.4",
"es6-promise": "3.0.2",
"grunt": "0.4.5",
"grunt-banner": "0.5.0",
"grunt-cli": "0.1.13",
"grunt-contrib-clean": "0.6.0",
"grunt-contrib-nodeunit": "0.4.1",
"grunt-contrib-watch": "0.6.1",
"grunt-eslint": "17.2.0",
"grunt-karma": "0.12.1",
"grunt-ts": "5.0.0-beta.5",
"grunt-update-json": "0.2.1",
"grunt-webpack": "1.0.11",
"jasmine-core": "2.3.4",
"karma": "0.13.10",
"karma-coverage": "0.5.2",
"karma-jasmine": "0.3.6",
"karma-jasmine-ajax": "0.1.13",
"karma-phantomjs-launcher": "0.2.1",
"karma-sourcemap-loader": "0.3.5",
"karma-webpack": "1.7.0",
"load-grunt-tasks": "3.3.0",
"minimist": "1.2.0",
"phantomjs": "1.9.18",
"webpack": "1.12.2",
"webpack-dev-server": "1.12.0"
},

@@ -56,0 +58,0 @@ "browser": {

@@ -7,3 +7,3 @@ # axios

[![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios)
[![dependency status](https://img.shields.io/david/mzabriskie/axios.svg?style=flat-square)](https://david-dm.org/mzabriskie/axios)
[![dev dependencies](https://img.shields.io/david/dev/mzabriskie/axios.svg?style=flat-square)](https://david-dm.org/mzabriskie/axios#info=devDependencies)

@@ -22,2 +22,8 @@ Promise based HTTP client for the browser and node.js

## Browser Support
![Chrome](https://raw.github.com/alrra/browser-logos/master/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/opera/opera_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/internet-explorer/internet-explorer_48x48.png) |
--- | --- | --- | --- | --- |
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 8+ ✔ |
## Installing

@@ -37,11 +43,2 @@

## Compatibility
Tested to work with >=IE8, Chrome, Firefox, Safari, and Opera.
## Promises
axios depends on a native ES6 Promise implementation to be [supported](http://caniuse.com/promises).
If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise)
## Example

@@ -291,3 +288,12 @@

## TypeScript Definition
## Semver
Until axios reaches a `1.0` release, breaking changes will be released with a new minor version. For example `0.5.1`, and `0.5.4` will have the same API, but `0.6.0` will have breaking changes.
## Promises
axios depends on a native ES6 Promise implementation to be [supported](http://caniuse.com/promises).
If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise).
## TypeScript
axios includes a [TypeScript](http://typescriptlang.org) definition.

@@ -294,0 +300,0 @@ ```typescript

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc