Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Object.entries(formData) in getFormData#1894

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dmitriyzhukcoso wants to merge1 commit intoferdikoomen:main
base:main
Choose a base branch
Loading
fromdmitriyzhukcoso:patch-1

Conversation

@dmitriyzhukcoso
Copy link

@dmitriyzhukcosodmitriyzhukcoso commentedNov 17, 2023
edited
Loading

When you use Object.entries(formData), it attempts to convert the FormData object into an array of key-value pairs, as it would with a regular JavaScript object. However, since FormData doesn't store its data in enumerable properties, Object.entries returns an empty array.

This will not work:

Object.entries(options.formData).filter(([_,value])=>isDefined(value)).forEach(([key,value])=>{if(Array.isArray(value)){value.forEach(v=>process(key,v));}else{process(key,value);}});

On the other hand, formData.entries() is a method specifically provided by the FormData interface. It returns an iterator allowing for the traversal of all key/value pairs contained in the FormData object. This method is designed to understand and interact with the internal structure of FormData, so it successfully retrieves the data.

This will work:

for(let[key,value]ofoptions.formData.entries()){if(isDefined(value)){if(Array.isArray(value)){value.forEach((v)=>process(key,v));}else{process(key,value);}}}

tajnymag reacted with thumbs up emoji
When you use Object.entries(formData), it attempts to convert the FormData object into an array of key-value pairs, as it would with a regular JavaScript object. However, since FormData doesn't store its data in enumerable properties, Object.entries returns an empty array.This will not work: Object.entries(options.formData)         .filter(([_, value]) => isDefined(value))        .forEach(([key, value]) => {            if (Array.isArray(value)) {                value.forEach(v => process(key, v));            } else {                process(key, value);            }        });On the other hand, formData.entries() is a method specifically provided by the FormData interface. It returns an iterator allowing for the traversal of all key/value pairs contained in the FormData object. This method is designed to understand and interact with the internal structure of FormData, so it successfully retrieves the data.This will work:for (let [key, value] of options.formData.entries()) {      if (isDefined(value)) {        if (Array.isArray(value)) {          value.forEach((v) => process(key, v));        } else {          process(key, value);        }      }    }
@dmitriyzhukcosodmitriyzhukcoso changed the titleFix for Object.entries(formData) in getFormDatafix: Object.entries(formData) in getFormDataNov 18, 2023
@dmitriyzhuk
Copy link

Hi, will this be added any time soon?

@stasdrvn
Copy link

+1, waiting for this fix as well

@illiaDream
Copy link

+1

@jordanshatford
Copy link

Check out our fork of this repository@hey-api/openapi-ts. We have fixed this issue inv0.32.1. If you run into any further issues, open an issue in our repository. Thanks.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@dmitriyzhukcoso@dmitriyzhuk@stasdrvn@illiaDream@jordanshatford

[8]ページ先頭

©2009-2025 Movatter.jp