mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
Added axios.formToJSON method; (#4735)
* Draft * Added `formDataToJSON` helper; Added `axios.formToJSON` method; Added client tests; Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
+5
-1
@@ -5,7 +5,7 @@ var bind = require('./helpers/bind');
|
||||
var Axios = require('./core/Axios');
|
||||
var mergeConfig = require('./core/mergeConfig');
|
||||
var defaults = require('./defaults');
|
||||
|
||||
var formDataToJSON = require('./helpers/formDataToJSON');
|
||||
/**
|
||||
* Create an instance of Axios
|
||||
*
|
||||
@@ -58,6 +58,10 @@ axios.spread = require('./helpers/spread');
|
||||
// Expose isAxiosError
|
||||
axios.isAxiosError = require('./helpers/isAxiosError');
|
||||
|
||||
axios.formToJSON = function(thing) {
|
||||
return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
||||
};
|
||||
|
||||
module.exports = axios;
|
||||
|
||||
// Allow use of default import syntax in TypeScript
|
||||
|
||||
Reference in New Issue
Block a user