Open felipeavila-vp opened 1 month ago
:warning: | Missing Reproducible Example |
---|---|
:information_source: | We could not detect a reproducible example in your issue report. Please provide either:
|
This issue still in
const formData = new FormData() formData.append('audio_file', { name: fileName, type: 'audio/mp3', uri: filePath })
await fetch('http endpoint', {
body: formData,
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data',
Authorization:
'Bearer token'
}
})
.then(res => {
console.log('test result ', res)
console.log('test result status ', res.status)
})
.catch(e => {
console.log('test e ', e)
})
This returns network error
REACT-NATIVE-INFO output:-
System: OS: macOS 14.2.1 CPU: (8) arm64 Apple M1 Memory: 599.88 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.19.0 path: ~/.nvm/versions/node/v18.19.0/bin/node Yarn: version: 3.6.4 path: /opt/homebrew/bin/yarn npm: version: 10.2.3 path: ~/.nvm/versions/node/v18.19.0/bin/npm Watchman: version: 2024.04.15.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms:
Same issue here..
const fileExtension = coverImage.split(".").pop();
// Create a new FormData instance
const formData = new FormData();
formData.append("image", {
uri: coverImage,
name: "image-" + new Date() + `.${fileExtension}`,
type: `image/${fileExtension}`,
} as any);
// Append other form fields to FormData
formData.append("food_name", data.food_name);
formData.append("description", data.description);
formData.append("price", String(data.price));
formData.append("category", data.category);
formData.append("addOn", JSON.stringify(data.addon));
// Append sizes if applicable
if (isSize && data.size.length > 0) {
data.size.forEach((input, index) => {
formData.append(`size[${index}]`, input.size);
formData.append(`size_price[${index}]`, String(input.price));
});
}
const response = await axios.post(
`${app_url}/addMenuItem/${resId}`,
formData,
{
headers: {
"Content-Type": "multipart/form-data",
},
}
);
When I console.log req.file and req.body,
undefined [Object: null prototype] { food_name: '', description: '', price: 'null', category: '', addOn: '{"addon":"","price":0}' }
Here I'm not sending any data in req.body only sending file to req.file which I get undefined.. This works fine with react native 0.73.x but not with 0.74.x
This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.
Same problem here yet
Description
When I try to send some post request sending a file with formData I receive a Network Error. Most of the time the request works fine, but sometimes I receive this error. The problem occurs when use Android, works fine with IOS.
Recently I updated my application to react-native 0.74.1(latest), before the version was 0.64.4. In older version all works fine.
Current versions:
Steps to reproduce
Only try to submit some files using formData
React Native Version
0.74.1
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com
Screenshots and Videos
No response