Skip to content

Conversation

@kuamanet
Copy link
Contributor

Fix #293
Fix #251


private createFormData(input: Record<string, unknown>): FormData {
return Object.keys(input || {}).reduce((formData, key) => {
let property = input[key];

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

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;

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

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
@kuamanet
Copy link
Contributor Author

@NooNoo1337 change requests applied :)

@NooNoo1337
Copy link

NooNoo1337 commented Mar 28, 2022

@kuamanet

Awesome! Thank you c:

@js2me
Copy link
Member

js2me commented Aug 15, 2022

@kuamanet hello, thank you for your Pull Request, can you resolve conflicts on this branch?

@js2me js2me deleted the branch acacode:next August 15, 2022 12:01
@js2me js2me closed this Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants