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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With