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

Env form data #4470

Merged
merged 6 commits into from Apr 1, 2022
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: 1 addition & 1 deletion lib/defaults.js
Expand Up @@ -77,7 +77,7 @@ var defaults = {
var contentType = headers && headers['Content-Type'];

if ( isObjectPayload && contentType === 'multipart/form-data' ) {
return toFormData(data, new (this.env && this.env.FormData || FormData));
return toFormData(data, this.env && this.env.FormData);
} else if ( isObjectPayload || contentType === 'application/json' ) {
setContentTypeIfUnset(headers, 'application/json');
return stringifySafely(data);
Expand Down
7 changes: 3 additions & 4 deletions lib/helpers/toFormData.js
Expand Up @@ -46,12 +46,11 @@ function buildFormData(formData, data, parentKey) {
* type FormVal = FormDataNest | FormDataPrimitive
*
* @param {FormVal} data
* @param {?Object} formData
* @param {?Class} EnvFormData
*/

module.exports = function getFormData(data, formData) {
// eslint-disable-next-line no-param-reassign
formData = formData || new FormData();
module.exports = function getFormData(data, EnvFormData) {
var formData = new (EnvFormData || FormData)();

buildFormData(formData, data);

Expand Down