I'm uploading images through fetch api. While uploading, if a single images is selected it works perfectly but if multiple images are selected it gives error [TypeError: Network request failed]. i have tried commenting initializeFlipper and looked this answer also.
Server takes array of images.. this is how images[] looks like when multiple images are selected
[{"height": 900, "mime": "image/jpeg", "modificationDate": "1649410153000", "path": "file:///data/user/0/com.emilio/cache/react-native-image-crop-picker/FB_IMG_1649005113656.jpg", "size": 78059, "width": 720}, {"height": 4160, "mime": "image/jpeg", "modificationDate": "1649410153000", "path": "file:///data/user/0/com.emilio/cache/react-native-image-crop-picker/IMG_20220330_134929_1.jpg", "size": 923567, "width": 1920}]
and this is how images looks like when single images is selected
[{"height": 725, "mime": "image/jpeg", "modificationDate": "1649410757000", "path": "file:///data/user/0/com.emilio/cache/react-native-image-crop-picker/FB_IMG_1649089342911.jpg", "size": 51443, "width": 720}]
this is my code:
const postOrder = () => {
var data = new FormData();
data.append('marca', marca);
data.append('modeo', modeo);
data.append('option', option);
data.append('description', description);
data.append('images[]', {
uri: images,
name: 'image.jpg',
type: 'image/jpeg',
});
data.append('userId', state.user.id);
dispatch(saveOrder(data));
};
export const saveOrder = data => dispatch => {
console.log('/data in order action', data);
fetch(`${baseUrl}/save-order`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'multipart/form-data',
},
body: data,
})
.then(res => res.json())
.then(json => {
console.log('json1', json);
alert('order placed');
})
.catch(error => {
console.log('error in saving', error);
});
};
Edit
checked with postman..multiple images are uploading successfully..this is how postman sending it. does anybody know how should i format images[] param

[TypeError: Network request failed] is thrown when the parameters you send are not correctly formatted. So try the other way I mentioned below.
Try doing a loop and append
images.map((file, index) => {
data.append(`images[${index}]`, {
uri: file,
name: 'image.jpg',
type: 'image/jpeg',
});
})
Also, ask your backend developer to check if they are accepting the file in the correct param and way. Cross-check the same with the postman to confirm.