From 989b4cfcec51ab64ac98669e61e3261a72995a28 Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Wed, 8 Apr 2015 14:44:41 -0600 Subject: [PATCH 01/14] Removing deprecated success/error aliases closes #57 --- lib/axios.js | 21 --------------------- test/specs/api.spec.js | 2 -- test/specs/promise.spec.js | 31 ------------------------------- 3 files changed, 54 deletions(-) diff --git a/lib/axios.js b/lib/axios.js index 0996d4d..6a6a551 100644 --- a/lib/axios.js +++ b/lib/axios.js @@ -2,7 +2,6 @@ var defaults = require('./defaults'); var utils = require('./utils'); -var deprecatedMethod = require('./helpers/deprecatedMethod'); var dispatchRequest = require('./core/dispatchRequest'); var InterceptorManager = require('./core/InterceptorManager'); @@ -43,26 +42,6 @@ var axios = module.exports = function axios(config) { promise = promise.then(chain.shift(), chain.shift()); } - // Provide alias for success - promise.success = function success(fn) { - deprecatedMethod('success', 'then', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api'); - - promise.then(function(response) { - fn(response.data, response.status, response.headers, response.config); - }); - return promise; - }; - - // Provide alias for error - promise.error = function error(fn) { - deprecatedMethod('error', 'catch', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api'); - - promise.then(null, function(response) { - fn(response.data, response.status, response.headers, response.config); - }); - return promise; - }; - return promise; }; diff --git a/test/specs/api.spec.js b/test/specs/api.spec.js index fbc8e5e..abfd286 100644 --- a/test/specs/api.spec.js +++ b/test/specs/api.spec.js @@ -15,8 +15,6 @@ describe('api', function () { expect(typeof promise.then).toEqual('function'); expect(typeof promise.catch).toEqual('function'); - expect(typeof promise.success).toEqual('function'); - expect(typeof promise.error).toEqual('function'); }); it('should have defaults', function () { diff --git a/test/specs/promise.spec.js b/test/specs/promise.spec.js index f15d626..36b9c64 100644 --- a/test/specs/promise.spec.js +++ b/test/specs/promise.spec.js @@ -37,37 +37,6 @@ describe('promise', function () { }, 0); }); - it('should provide verbose arguments to success', function (done) { - var request, data, status, headers, config; - - axios({ - url: '/foo' - }).success(function (d, s, h, c) { - data = d; - status = s; - headers = h; - config = c; - fulfilled = true; - }); - - setTimeout(function () { - request = jasmine.Ajax.requests.mostRecent(); - - request.respondWith({ - status: 200, - responseText: '{"hello":"world"}' - }); - - setTimeout(function () { - expect(data.hello).toEqual('world'); - expect(status).toBe(200); - expect(headers['content-type']).toEqual('application/json'); - expect(config.url).toEqual('/foo'); - done(); - }, 0); - }, 0); - }); - it('should support all', function (done) { var fulfilled = false; From a7caa97caa1a8680fd23dfe517e1649ec93b7a72 Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Wed, 8 Apr 2015 14:44:41 -0600 Subject: [PATCH 02/14] Removing deprecated success/error aliases closes #57 --- lib/axios.js | 21 --------------------- test/specs/api.spec.js | 2 -- test/specs/promise.spec.js | 31 ------------------------------- 3 files changed, 54 deletions(-) diff --git a/lib/axios.js b/lib/axios.js index 0996d4d..6a6a551 100644 --- a/lib/axios.js +++ b/lib/axios.js @@ -2,7 +2,6 @@ var defaults = require('./defaults'); var utils = require('./utils'); -var deprecatedMethod = require('./helpers/deprecatedMethod'); var dispatchRequest = require('./core/dispatchRequest'); var InterceptorManager = require('./core/InterceptorManager'); @@ -43,26 +42,6 @@ var axios = module.exports = function axios(config) { promise = promise.then(chain.shift(), chain.shift()); } - // Provide alias for success - promise.success = function success(fn) { - deprecatedMethod('success', 'then', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api'); - - promise.then(function(response) { - fn(response.data, response.status, response.headers, response.config); - }); - return promise; - }; - - // Provide alias for error - promise.error = function error(fn) { - deprecatedMethod('error', 'catch', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api'); - - promise.then(null, function(response) { - fn(response.data, response.status, response.headers, response.config); - }); - return promise; - }; - return promise; }; diff --git a/test/specs/api.spec.js b/test/specs/api.spec.js index fbc8e5e..abfd286 100644 --- a/test/specs/api.spec.js +++ b/test/specs/api.spec.js @@ -15,8 +15,6 @@ describe('api', function () { expect(typeof promise.then).toEqual('function'); expect(typeof promise.catch).toEqual('function'); - expect(typeof promise.success).toEqual('function'); - expect(typeof promise.error).toEqual('function'); }); it('should have defaults', function () { diff --git a/test/specs/promise.spec.js b/test/specs/promise.spec.js index f15d626..36b9c64 100644 --- a/test/specs/promise.spec.js +++ b/test/specs/promise.spec.js @@ -37,37 +37,6 @@ describe('promise', function () { }, 0); }); - it('should provide verbose arguments to success', function (done) { - var request, data, status, headers, config; - - axios({ - url: '/foo' - }).success(function (d, s, h, c) { - data = d; - status = s; - headers = h; - config = c; - fulfilled = true; - }); - - setTimeout(function () { - request = jasmine.Ajax.requests.mostRecent(); - - request.respondWith({ - status: 200, - responseText: '{"hello":"world"}' - }); - - setTimeout(function () { - expect(data.hello).toEqual('world'); - expect(status).toBe(200); - expect(headers['content-type']).toEqual('application/json'); - expect(config.url).toEqual('/foo'); - done(); - }, 0); - }, 0); - }); - it('should support all', function (done) { var fulfilled = false; From 1695f5cffe557381cea3b73268fff6f688c5934d Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Thu, 18 Jun 2015 21:56:22 -0600 Subject: [PATCH 03/14] Adding support for timeout config closes #56 --- lib/adapters/http.js | 5 +++++ lib/adapters/xhr.js | 3 +++ lib/defaults.js | 2 ++ 3 files changed, 10 insertions(+) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index 84a89be..bcb11ea 100644 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -88,6 +88,11 @@ module.exports = function httpAdapter(resolve, reject, config) { reject(err); }); + // Handle request timeout + req.setTimeout(config.timeout, function () { + req.abort(); + }); + // Send the request req.end(data); }; diff --git a/lib/adapters/xhr.js b/lib/adapters/xhr.js index dc5c6d0..73886a0 100644 --- a/lib/adapters/xhr.js +++ b/lib/adapters/xhr.js @@ -36,6 +36,9 @@ module.exports = function xhrAdapter(resolve, reject, config) { var request = new (XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP'); request.open(config.method.toUpperCase(), buildUrl(config.url, config.params), true); + // Set the request timeout in MS + request.timeout = config.timeout; + // Listen for ready state request.onreadystatechange = function () { if (request && request.readyState === 4) { diff --git a/lib/defaults.js b/lib/defaults.js index 5d8aac7..b2d83e0 100644 --- a/lib/defaults.js +++ b/lib/defaults.js @@ -47,6 +47,8 @@ module.exports = { put: utils.merge(DEFAULT_CONTENT_TYPE) }, + timeout: 0, + xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN' }; From c42b0ae438fe8bb4d0223b1888dd6818a836e555 Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Thu, 18 Jun 2015 22:49:36 -0600 Subject: [PATCH 04/14] Removing es6-promise dependency --- lib/axios.js | 10 ---------- package.json | 4 +--- test/specs/promise.spec.js | 1 + 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/axios.js b/lib/axios.js index 6a6a551..57b770e 100644 --- a/lib/axios.js +++ b/lib/axios.js @@ -5,16 +5,6 @@ var utils = require('./utils'); var dispatchRequest = require('./core/dispatchRequest'); var InterceptorManager = require('./core/InterceptorManager'); -// Polyfill ES6 Promise if needed -(function () { - // webpack is being used to set es6-promise to the native Promise - // for the standalone build. It's necessary to make sure polyfill exists. - var P = require('es6-promise'); - if (P && typeof P.polyfill === 'function') { - P.polyfill(); - } -})(); - var axios = module.exports = function axios(config) { config = utils.merge({ method: 'get', diff --git a/package.json b/package.json index ad9131a..79e143b 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,9 @@ "url": "https://github.com/mzabriskie/axios/issues" }, "homepage": "https://github.com/mzabriskie/axios", - "dependencies": { - "es6-promise": "^2.3.0" - }, "devDependencies": { "coveralls": "^2.11.2", + "es6-promise": "^2.3.0", "grunt": "^0.4.5", "grunt-banner": "^0.4.0", "grunt-contrib-clean": "^0.6.0", diff --git a/test/specs/promise.spec.js b/test/specs/promise.spec.js index 36b9c64..5dd5088 100644 --- a/test/specs/promise.spec.js +++ b/test/specs/promise.spec.js @@ -1,3 +1,4 @@ +require('es6-promise').polyfill(); var axios = require('../../index'); describe('promise', function () { From 8df6b4cb1b47145b012d5c4f9df05d5d9e848d9b Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Thu, 18 Jun 2015 22:53:13 -0600 Subject: [PATCH 05/14] Converting to UMD --- webpack.config.js | 85 ++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 52 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 161f70a..9254bd6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,60 +1,41 @@ var webpack = require('webpack'); - -var EXTERNAL_PROMISE = '{Promise: Promise}'; var config = {}; -var base = { - entry: './index.js', - output: { - path: 'dist/', - filename: 'axios.js', - sourceMapFilename: 'axios.map', - library: 'axios' - }, - externals: [ - { - './adapters/http': 'var undefined' - } - ], - devtool: 'source-map' -}; -['amd', 'global', 'amd-standalone', 'global-standalone'].forEach(function (key) { - config[key] = JSON.parse(JSON.stringify(base)); - config[key + '-min'] = JSON.parse(JSON.stringify(base)); +function generateConfig(name) { + var uglify = name.indexOf('min') > -1; + var config = { + entry: './index.js', + output: { + path: 'dist/', + filename: name + '.js', + sourceMapFilename: name + '.map', + library: 'axios', + libraryTarget: 'umd' + }, + externals: [ + { + './adapters/http': 'var undefined' + } + ], + devtool: 'source-map' + }; + + if (uglify) { + config.plugins = [ + new webpack.optimize.UglifyJsPlugin({ + compressor: { + warnings: false + } + }) + ]; + } - config[key + '-min'].plugins = [ - new webpack.optimize.UglifyJsPlugin() - ]; + return config; +} + +['axios', 'axios.min'].forEach(function (key) { + config[key] = generateConfig(key); }); -config['amd'].output.filename = 'axios.amd.js'; -config['amd'].output.sourceMapFilename = 'axios.amd.map'; -config['amd'].output.libraryTarget = 'amd'; - -config['amd-standalone'].output.filename = 'axios.amd.standalone.js'; -config['amd-standalone'].output.sourceMapFilename = 'axios.amd.standalone.map'; -config['amd-standalone'].output.libraryTarget = 'amd'; -config['amd-standalone'].externals[0]['es6-promise'] = EXTERNAL_PROMISE; - -config['amd-min'].output.filename = 'axios.amd.min.js'; -config['amd-min'].output.sourceMapFilename = 'axios.amd.min.map'; -config['amd-min'].output.libraryTarget = 'amd'; - -config['amd-standalone-min'].output.filename = 'axios.amd.standalone.min.js'; -config['amd-standalone-min'].output.sourceMapFilename = 'axios.amd.standalone.min.map'; -config['amd-standalone-min'].output.libraryTarget = 'amd'; -config['amd-standalone-min'].externals[0]['es6-promise'] = EXTERNAL_PROMISE; - -config['global-standalone'].output.filename = 'axios.standalone.js'; -config['global-standalone'].output.sourceMapFilename = 'axios.standalone.map'; -config['global-standalone'].externals[0]['es6-promise'] = EXTERNAL_PROMISE; - -config['global-min'].output.filename = 'axios.min.js'; -config['global-min'].output.sourceMapFilename = 'axios.min.map'; - -config['global-standalone-min'].output.filename = 'axios.standalone.min.js'; -config['global-standalone-min'].output.sourceMapFilename = 'axios.standalone.min.map'; -config['global-standalone-min'].externals[0]['es6-promise'] = EXTERNAL_PROMISE; - module.exports = config; From 0f02a5a51f73c138fae1655e071c83838a785610 Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Thu, 18 Jun 2015 23:15:56 -0600 Subject: [PATCH 06/14] Updating README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5cba5ed..62879c8 100644 --- a/README.md +++ b/README.md @@ -174,6 +174,10 @@ This is the available config options for making requests. Only the `url` is requ firstName: 'Fred' }, + // `timeout` specifies the number of milliseconds before the request times out. + // If the request takes longer than `timeout`, the request will be aborted. + timeout: 1000, + // `withCredentials` indicates whether or not cross-site Access-Control requests // should be made using credentials withCredentials: false, // default From 58a35df2bd61d2bc6bc2795879c770a3ec92edca Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Thu, 18 Jun 2015 23:19:26 -0600 Subject: [PATCH 07/14] Updating README --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 62879c8..cfac61b 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,11 @@ $ npm install axios 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 Performing a `GET` request @@ -292,8 +297,6 @@ axios.get('/user?ID=12345'); axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular. -axios uses the [es6-promise](https://github.com/jakearchibald/es6-promise) polyfill by [Jake Archibald](https://github.com/jakearchibald). Until we [can use](http://caniuse.com/promises) ES6 Promises natively in all browsers, this polyfill is a life saver. - ## License MIT From 87427d37e7da14c35e0d68ffa43685da8f2c85a6 Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Wed, 8 Apr 2015 14:44:41 -0600 Subject: [PATCH 08/14] Removing deprecated success/error aliases closes #57 --- lib/axios.js | 21 --------------------- test/specs/api.spec.js | 2 -- test/specs/promise.spec.js | 31 ------------------------------- 3 files changed, 54 deletions(-) diff --git a/lib/axios.js b/lib/axios.js index 0996d4d..6a6a551 100644 --- a/lib/axios.js +++ b/lib/axios.js @@ -2,7 +2,6 @@ var defaults = require('./defaults'); var utils = require('./utils'); -var deprecatedMethod = require('./helpers/deprecatedMethod'); var dispatchRequest = require('./core/dispatchRequest'); var InterceptorManager = require('./core/InterceptorManager'); @@ -43,26 +42,6 @@ var axios = module.exports = function axios(config) { promise = promise.then(chain.shift(), chain.shift()); } - // Provide alias for success - promise.success = function success(fn) { - deprecatedMethod('success', 'then', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api'); - - promise.then(function(response) { - fn(response.data, response.status, response.headers, response.config); - }); - return promise; - }; - - // Provide alias for error - promise.error = function error(fn) { - deprecatedMethod('error', 'catch', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api'); - - promise.then(null, function(response) { - fn(response.data, response.status, response.headers, response.config); - }); - return promise; - }; - return promise; }; diff --git a/test/specs/api.spec.js b/test/specs/api.spec.js index fbc8e5e..abfd286 100644 --- a/test/specs/api.spec.js +++ b/test/specs/api.spec.js @@ -15,8 +15,6 @@ describe('api', function () { expect(typeof promise.then).toEqual('function'); expect(typeof promise.catch).toEqual('function'); - expect(typeof promise.success).toEqual('function'); - expect(typeof promise.error).toEqual('function'); }); it('should have defaults', function () { diff --git a/test/specs/promise.spec.js b/test/specs/promise.spec.js index f15d626..36b9c64 100644 --- a/test/specs/promise.spec.js +++ b/test/specs/promise.spec.js @@ -37,37 +37,6 @@ describe('promise', function () { }, 0); }); - it('should provide verbose arguments to success', function (done) { - var request, data, status, headers, config; - - axios({ - url: '/foo' - }).success(function (d, s, h, c) { - data = d; - status = s; - headers = h; - config = c; - fulfilled = true; - }); - - setTimeout(function () { - request = jasmine.Ajax.requests.mostRecent(); - - request.respondWith({ - status: 200, - responseText: '{"hello":"world"}' - }); - - setTimeout(function () { - expect(data.hello).toEqual('world'); - expect(status).toBe(200); - expect(headers['content-type']).toEqual('application/json'); - expect(config.url).toEqual('/foo'); - done(); - }, 0); - }, 0); - }); - it('should support all', function (done) { var fulfilled = false; From cc451b38c159841a283067a57220c0e6e985a139 Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Thu, 18 Jun 2015 21:56:22 -0600 Subject: [PATCH 09/14] Adding support for timeout config closes #56 --- lib/adapters/http.js | 5 +++++ lib/adapters/xhr.js | 3 +++ lib/defaults.js | 2 ++ 3 files changed, 10 insertions(+) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index 84a89be..bcb11ea 100644 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -88,6 +88,11 @@ module.exports = function httpAdapter(resolve, reject, config) { reject(err); }); + // Handle request timeout + req.setTimeout(config.timeout, function () { + req.abort(); + }); + // Send the request req.end(data); }; diff --git a/lib/adapters/xhr.js b/lib/adapters/xhr.js index dc5c6d0..73886a0 100644 --- a/lib/adapters/xhr.js +++ b/lib/adapters/xhr.js @@ -36,6 +36,9 @@ module.exports = function xhrAdapter(resolve, reject, config) { var request = new (XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP'); request.open(config.method.toUpperCase(), buildUrl(config.url, config.params), true); + // Set the request timeout in MS + request.timeout = config.timeout; + // Listen for ready state request.onreadystatechange = function () { if (request && request.readyState === 4) { diff --git a/lib/defaults.js b/lib/defaults.js index 94e9d44..ba2ca8e 100644 --- a/lib/defaults.js +++ b/lib/defaults.js @@ -55,6 +55,8 @@ module.exports = { put: utils.merge(DEFAULT_CONTENT_TYPE) }, + timeout: 0, + xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN' }; From e8cf487ad0f5386313dd13f4914c8e49d4272fa4 Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Thu, 18 Jun 2015 22:49:36 -0600 Subject: [PATCH 10/14] Removing es6-promise dependency --- lib/axios.js | 10 ---------- package.json | 4 +--- test/specs/promise.spec.js | 1 + 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/axios.js b/lib/axios.js index 6a6a551..57b770e 100644 --- a/lib/axios.js +++ b/lib/axios.js @@ -5,16 +5,6 @@ var utils = require('./utils'); var dispatchRequest = require('./core/dispatchRequest'); var InterceptorManager = require('./core/InterceptorManager'); -// Polyfill ES6 Promise if needed -(function () { - // webpack is being used to set es6-promise to the native Promise - // for the standalone build. It's necessary to make sure polyfill exists. - var P = require('es6-promise'); - if (P && typeof P.polyfill === 'function') { - P.polyfill(); - } -})(); - var axios = module.exports = function axios(config) { config = utils.merge({ method: 'get', diff --git a/package.json b/package.json index ad9131a..79e143b 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,9 @@ "url": "https://github.com/mzabriskie/axios/issues" }, "homepage": "https://github.com/mzabriskie/axios", - "dependencies": { - "es6-promise": "^2.3.0" - }, "devDependencies": { "coveralls": "^2.11.2", + "es6-promise": "^2.3.0", "grunt": "^0.4.5", "grunt-banner": "^0.4.0", "grunt-contrib-clean": "^0.6.0", diff --git a/test/specs/promise.spec.js b/test/specs/promise.spec.js index 36b9c64..5dd5088 100644 --- a/test/specs/promise.spec.js +++ b/test/specs/promise.spec.js @@ -1,3 +1,4 @@ +require('es6-promise').polyfill(); var axios = require('../../index'); describe('promise', function () { From ebeb2221d9533c902c6613b77197df63fb90570b Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Thu, 18 Jun 2015 22:53:13 -0600 Subject: [PATCH 11/14] Converting to UMD --- webpack.config.js | 85 ++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 52 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 161f70a..9254bd6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,60 +1,41 @@ var webpack = require('webpack'); - -var EXTERNAL_PROMISE = '{Promise: Promise}'; var config = {}; -var base = { - entry: './index.js', - output: { - path: 'dist/', - filename: 'axios.js', - sourceMapFilename: 'axios.map', - library: 'axios' - }, - externals: [ - { - './adapters/http': 'var undefined' - } - ], - devtool: 'source-map' -}; -['amd', 'global', 'amd-standalone', 'global-standalone'].forEach(function (key) { - config[key] = JSON.parse(JSON.stringify(base)); - config[key + '-min'] = JSON.parse(JSON.stringify(base)); +function generateConfig(name) { + var uglify = name.indexOf('min') > -1; + var config = { + entry: './index.js', + output: { + path: 'dist/', + filename: name + '.js', + sourceMapFilename: name + '.map', + library: 'axios', + libraryTarget: 'umd' + }, + externals: [ + { + './adapters/http': 'var undefined' + } + ], + devtool: 'source-map' + }; + + if (uglify) { + config.plugins = [ + new webpack.optimize.UglifyJsPlugin({ + compressor: { + warnings: false + } + }) + ]; + } - config[key + '-min'].plugins = [ - new webpack.optimize.UglifyJsPlugin() - ]; + return config; +} + +['axios', 'axios.min'].forEach(function (key) { + config[key] = generateConfig(key); }); -config['amd'].output.filename = 'axios.amd.js'; -config['amd'].output.sourceMapFilename = 'axios.amd.map'; -config['amd'].output.libraryTarget = 'amd'; - -config['amd-standalone'].output.filename = 'axios.amd.standalone.js'; -config['amd-standalone'].output.sourceMapFilename = 'axios.amd.standalone.map'; -config['amd-standalone'].output.libraryTarget = 'amd'; -config['amd-standalone'].externals[0]['es6-promise'] = EXTERNAL_PROMISE; - -config['amd-min'].output.filename = 'axios.amd.min.js'; -config['amd-min'].output.sourceMapFilename = 'axios.amd.min.map'; -config['amd-min'].output.libraryTarget = 'amd'; - -config['amd-standalone-min'].output.filename = 'axios.amd.standalone.min.js'; -config['amd-standalone-min'].output.sourceMapFilename = 'axios.amd.standalone.min.map'; -config['amd-standalone-min'].output.libraryTarget = 'amd'; -config['amd-standalone-min'].externals[0]['es6-promise'] = EXTERNAL_PROMISE; - -config['global-standalone'].output.filename = 'axios.standalone.js'; -config['global-standalone'].output.sourceMapFilename = 'axios.standalone.map'; -config['global-standalone'].externals[0]['es6-promise'] = EXTERNAL_PROMISE; - -config['global-min'].output.filename = 'axios.min.js'; -config['global-min'].output.sourceMapFilename = 'axios.min.map'; - -config['global-standalone-min'].output.filename = 'axios.standalone.min.js'; -config['global-standalone-min'].output.sourceMapFilename = 'axios.standalone.min.map'; -config['global-standalone-min'].externals[0]['es6-promise'] = EXTERNAL_PROMISE; - module.exports = config; From f8fbd6ed4e35f8d1e84e80c66315eaf5b2b6ce97 Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Thu, 18 Jun 2015 23:15:56 -0600 Subject: [PATCH 12/14] Updating README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5cba5ed..62879c8 100644 --- a/README.md +++ b/README.md @@ -174,6 +174,10 @@ This is the available config options for making requests. Only the `url` is requ firstName: 'Fred' }, + // `timeout` specifies the number of milliseconds before the request times out. + // If the request takes longer than `timeout`, the request will be aborted. + timeout: 1000, + // `withCredentials` indicates whether or not cross-site Access-Control requests // should be made using credentials withCredentials: false, // default From 34ce57ade8853a1a251d3664a1f2b66e15c5fdcf Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Thu, 18 Jun 2015 23:19:26 -0600 Subject: [PATCH 13/14] Updating README --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 62879c8..cfac61b 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,11 @@ $ npm install axios 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 Performing a `GET` request @@ -292,8 +297,6 @@ axios.get('/user?ID=12345'); axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular. -axios uses the [es6-promise](https://github.com/jakearchibald/es6-promise) polyfill by [Jake Archibald](https://github.com/jakearchibald). Until we [can use](http://caniuse.com/promises) ES6 Promises natively in all browsers, this polyfill is a life saver. - ## License MIT From e633c4d01d0e2f3f7fe950e691f8fb2c3502fb04 Mon Sep 17 00:00:00 2001 From: mzabriskie Date: Mon, 10 Aug 2015 18:59:34 -0600 Subject: [PATCH 14/14] Updating dependencies --- package.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 79e143b..a2451f5 100644 --- a/package.json +++ b/package.json @@ -27,30 +27,30 @@ }, "homepage": "https://github.com/mzabriskie/axios", "devDependencies": { - "coveralls": "^2.11.2", - "es6-promise": "^2.3.0", + "coveralls": "^2.11.3", + "es6-promise": "^3.0.2", "grunt": "^0.4.5", "grunt-banner": "^0.4.0", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-nodeunit": "^0.4.1", "grunt-contrib-watch": "^0.6.1", - "grunt-eslint": "^15.0.0", - "grunt-karma": "^0.11.0", - "grunt-ts": "^4.2.0-beta", + "grunt-eslint": "^17.1.0", + "grunt-karma": "^0.12.0", + "grunt-ts": "^4.2.0", "grunt-update-json": "^0.2.1", - "grunt-webpack": "^1.0.8", + "grunt-webpack": "^1.0.11", "jasmine-core": "^2.3.4", - "karma": "^0.12.36", - "karma-coverage": "^0.4.2", - "karma-jasmine": "^0.3.5", + "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.0", + "karma-phantomjs-launcher": "^0.2.1", "karma-sourcemap-loader": "^0.3.5", - "karma-webpack": "^1.5.1", + "karma-webpack": "^1.7.0", "load-grunt-tasks": "^3.2.0", - "minimist": "^1.1.1", - "webpack": "^1.9.11", - "webpack-dev-server": "^1.9.0" + "minimist": "^1.1.3", + "webpack": "^1.11.0", + "webpack-dev-server": "^1.10.1" }, "browser": { "./lib/adapters/http.js": "./lib/adapters/xhr.js"