I try do the next fetch with react-native android 12 API 28
(import FormData from 'form-data';)
let formData = new FormData();
const file = new File(["foo"], "foo.txt",
"text/plain",
);
let textFile = {
uri: file.uri,
name: "foo.txt",
type: "text/plain"
};
formData.append("photo", textFile);
formData.append('description', 'helli');
fetch(url, {
method: 'post',
headers: formData.getHeaders,
body: formData
}).then(response => {
console.log("image uploaded")
}).catch(err => {
console.log(err)
})
y Try with localhost (http) and heroku (https) but it does not work
The Error is: [TypeError: Network request failed]
the description field is fine but the file appears as null