Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OPTIONS-method as a shortcut #461

Merged
merged 2 commits into from Mar 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -139,6 +139,7 @@ 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]])
Expand Down Expand Up @@ -175,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]])
Expand Down
2 changes: 1 addition & 1 deletion lib/core/Axios.js
Expand Up @@ -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 || {}, {
Expand Down
2 changes: 2 additions & 0 deletions test/specs/api.spec.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down