How to upload a file along with text using fetch in react native?

How to upload a file along with text using fetch in react native?

I'm trying to upload a file to the server using react-native-document-picker. The problem I'm facing is I don't know how to upload the file along with a text.In my app there is a portion for file upload also there is an area for writing some text.Then it will get uploaded to the server.So I've done the following.But I'm getting this error after submitting to server

I'm trying to upload a file to the server using react-native-document-picker. The problem I'm facing is I don't know how to upload the file along with a text.In my app there is a portion for file upload also there is an area for writing some text.Then it will get uploaded to the server.So I've done the following.But I'm getting this error after submitting to server

unhandled promise rejection unsupported BodyInit type

sample code

 filepick = () => {
        DocumentPicker.show({
            filetype: [DocumentPickerUtil.allFiles()],
        }, (error, res) => {

        console.log(
            res.uri,
            res.type, // mime type
            res.fileName,
            res.fileSize
        );
        Alert.alert(res.fileName)
        Alert.alert
        this.setState({ file: res.fileName })

    });
};

onPressSubmit() { fetch(GLOBAL.ASMNT_URL +${this.props.id}, { method: 'POST', headers: { 'Accept': "multipart/form-data", 'Content-Type': 'multipart/form-data' }, body: ({ file: this.state.file, comment: this.state.text })

    }).then(response => response.json())
        .then(responseData => {
            this.setState({
                assgn: responseData

            });

            console.log(this.state.assgn);

        });
}

The function filepick() is called after choosing a file from your device.Please help me to find a solution.How do I upload this to server also how to send text without stringifying it?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

React Native Map components for iOS + Android

React Native Map components for iOS + Android.Contribute to react-native-community/react-native-maps development by creating an account on GitHub

How to build a news app with JavaScript and React Native

How to build a news app with JavaScript and React Native

How to Build React Native Wrappers for Native SDKs

React native is an open-source framework for cross-platform mobile development that lets us build mobile apps using Javascript. It works by providing a bridge that facilitates the communication between Javascript and native modules. In this post, we discuss How to Build React Native Wrappers for Native SDKs