-
-
Notifications
You must be signed in to change notification settings - Fork 125
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 the option to use FormData to encode the form elements #153
Conversation
If the form's enctype attribute is set to "multipart/form-data", use FormData to encode the form's elements.
options.requestOptions.formData = new FormData(el) | ||
} | ||
else { | ||
options.requestOptions.requestParams = parseFormElements(el) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove requestParams: []
from line 19 now, as this makes that initialisation redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
lib/send-request.js
Outdated
@@ -51,6 +51,9 @@ module.exports = function(location, options, callback) { | |||
break | |||
} | |||
} | |||
else if (requestOptions.formData) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should either add var formData = requestOptions. formData || null
on line 9 to match the corresponding requestParams
variable we use in this module, and then replace all other instances of requestOptions.formData
with formData
or remove var requestParams = requestOptions.requestParams || null
from line 8 and replace all instances of requestParams
with requestOptions.requestParams
.
I think you'll also need to update your TypeScript definitions as part of this, is that correct? |
Good point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for actioning my feedback, LGTM 👍
It's great to have a second pair of eyes on it. There's always something that I miss. So thanks for that. |
Nice one on getting this feature in there, I think it's probably time we pushed out a new version now! |
I'm going to start working on that. |
Great, let me know if there's anything I can do to help. |
If the form's
enctype
attribute is set tomultipart/form-data
, useFormData
to encode the form's elements.Fixes #132.