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 1 commit
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
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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]])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The options method does not accept data parameter. Could you please remove data and place options between head and post in README.md?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sure!


###### NOTE
When using the alias methods `url`, `method`, and `data` properties don't need to be specified in 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