2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-30 15:24:11 +03:00
Files
axios/lib/helpers/toURLEncodedForm.js
T
Dmitriy Mozgovoy c05ad48952 Fixed toFormData regression bug (unreleased) with Array-like objects serialization; (#4714)
Added `toURLEncodedForm` helper;
Added automatic payload serialization to `application/x-www-form-urlencoded` to have parity with `multipart/form-data`;
Added test of handling `application/x-www-form-urlencoded` body by express.js;
Updated README.md;
Added missed param in JSDoc;
Fixed hrefs in README.md;

Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-05-16 08:30:17 +02:00

19 lines
513 B
JavaScript

'use strict';
var utils = require('../utils');
var toFormData = require('./toFormData');
var platform = require('../platform/');
module.exports = function toURLEncodedForm(data) {
return toFormData(data, new platform.classes.URLSearchParams(), {
visitor: function(value, key, path, helpers) {
if (platform.isNode && utils.isBuffer(value)) {
this.append(key, value.toString('base64'));
return false;
}
return helpers.defaultVisitor.apply(this, arguments);
}
});
};