From 2e0adc1cae76eb214800ce64cfb5d27c032c8556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teemu=20Heikkil=C3=A4?= Date: Thu, 29 Sep 2016 18:54:17 +0300 Subject: [PATCH 1/2] Add OPTIONS-method as a shortcut --- README.md | 1 + lib/core/Axios.js | 2 +- test/specs/api.spec.js | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6c42a02716..40fbfdee0c 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ For convenience aliases have been provided for all supported request methods. ##### axios.post(url[, data[, config]]) ##### axios.put(url[, data[, config]]) ##### axios.patch(url[, data[, config]]) +##### axios.options(url[, data[, config]]) ###### NOTE When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config. diff --git a/lib/core/Axios.js b/lib/core/Axios.js index 5ace5cb0d1..15ce89c1b9 100644 --- a/lib/core/Axios.js +++ b/lib/core/Axios.js @@ -61,7 +61,7 @@ Axios.prototype.request = function request(config) { }; // Provide aliases for supported request methods -utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { +utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { /*eslint func-names:0*/ Axios.prototype[method] = function(url, config) { return this.request(utils.merge(config || {}, { diff --git a/test/specs/api.spec.js b/test/specs/api.spec.js index 937f124595..31fdbaf505 100644 --- a/test/specs/api.spec.js +++ b/test/specs/api.spec.js @@ -3,6 +3,7 @@ describe('static api', function () { expect(typeof axios.request).toEqual('function'); expect(typeof axios.get).toEqual('function'); expect(typeof axios.head).toEqual('function'); + expect(typeof axios.options).toEqual('function'); expect(typeof axios.delete).toEqual('function'); expect(typeof axios.post).toEqual('function'); expect(typeof axios.put).toEqual('function'); @@ -42,6 +43,7 @@ describe('instance api', function () { it('should have request methods', function () { expect(typeof instance.request).toEqual('function'); expect(typeof instance.get).toEqual('function'); + expect(typeof instance.options).toEqual('function'); expect(typeof instance.head).toEqual('function'); expect(typeof instance.delete).toEqual('function'); expect(typeof instance.post).toEqual('function'); From 8cdfcd02849057d901b2140b7d398f34a0e2685e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teemu=20Heikkil=C3=A4?= Date: Sun, 26 Mar 2017 10:39:53 +0300 Subject: [PATCH 2/2] Fix options params, Change the order, Add documentation for instance also --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 40fbfdee0c..6c3a472fb8 100644 --- a/README.md +++ b/README.md @@ -139,10 +139,10 @@ For convenience aliases have been provided for all supported request methods. ##### axios.get(url[, config]) ##### axios.delete(url[, config]) ##### axios.head(url[, config]) +##### axios.options(url[, config]) ##### axios.post(url[, data[, config]]) ##### axios.put(url[, data[, config]]) ##### axios.patch(url[, data[, config]]) -##### axios.options(url[, data[, config]]) ###### NOTE When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config. @@ -176,6 +176,7 @@ The available instance methods are listed below. The specified config will be me ##### axios#get(url[, config]) ##### axios#delete(url[, config]) ##### axios#head(url[, config]) +##### axios#options(url[, config]) ##### axios#post(url[, data[, config]]) ##### axios#put(url[, data[, config]]) ##### axios#patch(url[, data[, config]])