-
-
Notifications
You must be signed in to change notification settings - Fork 419
Fix request format and allow for files in request #332
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
Conversation
|
|
||
| private createFormData(input: Record<string, unknown>): FormData { | ||
| return Object.keys(input || {}).reduce((formData, key) => { | ||
| let property = input[key]; |
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.
suggestion: lets make it as const. The value of variable doesn't change
| for (const formItem of propertyContent) { | ||
| formData.append( | ||
| key, | ||
| formItem instanceof Blob || formItem instanceof File |
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.
suggestion: to make external variable for condition to simplify double ternary condition.
const isFileType = formItem instanceof Blob || formItem instanceof File;
| {}; | ||
| const requestParams = this.mergeRequestParams(params, secureParams); | ||
| const responseFormat = (format && this.format) || void 0; | ||
| const responseFormat = format || this.format || void 0; |
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.
suggestion: void 0 -> undefined?
| key, | ||
| formItem instanceof Blob || formItem instanceof File | ||
| ? formItem | ||
| : typeof formItem === "object" && formItem !== null |
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.
suggestion: get rid of the nested condition. Because it is hard to read and understand from scratch.
? formItem : stringifyFormItem(formItem)
stringifyFormItem(formItem) {
if( typeof formItem === "object" && formItem !== null ) return JSON.stringify(formItem);
return `${formItem}`;
}
allow for file array in form data requests
|
@NooNoo1337 change requests applied :) |
|
Awesome! Thank you c: |
|
@kuamanet hello, thank you for your Pull Request, can you resolve conflicts on this branch? |
Fix #293
Fix #251