My code:
const file = {
uri: this.state.imageSource,
name: this.state.imageName,
type: 'image/jpg',
};
const data = new FormData();
data.append('file', file);
fetch(config.server + '/upload', {
method: 'POST',
body: data,
})
.then((res) => res.json())
.then((responseData) => {
alert(JSON.stringify(responseData));
})
.catch((err) => {
alert(err);
});
Without FormData code doesnt display error. What I should do to fix? Debugging on android.
The error was because I was passing in the url as an array but it expected a string.
This will resolve the issue :
alert(JSON.stringify(data))
I was getting this error because my URL was incorrect
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