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

axios delete method's arguments are placed wrong #14

Open
codexp opened this issue Jun 19, 2017 · 0 comments
Open

axios delete method's arguments are placed wrong #14

codexp opened this issue Jun 19, 2017 · 0 comments

Comments

@codexp
Copy link

codexp commented Jun 19, 2017

Please consider following axios implementation of arguments:

	// Provide aliases for supported request methods
	utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
	  /*eslint func-names:0*/
	  Axios.prototype[method] = function(url, config) {
	    return this.request(utils.merge(config || {}, {
	      method: method,
	      url: url
	    }));
	  };
	});
	
	utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
	  /*eslint func-names:0*/
	  Axios.prototype[method] = function(url, data, config) {
	    return this.request(utils.merge(config || {}, {
	      method: method,
	      url: url,
	      data: data
	    }));
	  };
	});

therefore data is passed as config when delete method of the form is called.
If the form would have a field called 'data', there will be a silent error before the request is even made.

here is an example:

    const form = new Form({ data: 'this will fail before request' });

    form.delete('item/1') // no request is made
        .then(data => alert('done!'))
        .catch(error => alert('something is gone wrong!')); // catch fires with TypeError: _this.data is not a function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant