6

I am working on a react native project. I am using FormData to upload my files and input text.

But in form validation, I need to get the Value from the FormData object. I tried formData.get('mykey') but it gives me an error that gets is not a function. Can anyone please tell me how can I do that?

thanks.

1 Answer 1

14

You can use FormData#getParts:

const field = data.getParts().find(item => item.fieldName === 'key'));
if (field) {
  const value = field.string;
}

See relevant React Native source code for FormData.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.