Reputation: 1619
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.
Upvotes: 3
Views: 3156
Reputation: 35910
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.
Upvotes: 12