Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 30350

Error: Network Error Axios - Image React Native

$
0
0

Im trying to post an Image to server but axios throw an error saying

[Error: Network Error]

I created a bodyFormData and appended the following

bodyFormData.append('image', {          name: imgName,          type: 'image/jpeg',          uri: this.state.image,        });

where my imageName is just a string and the this.state.image is the file path file:///storage/emulated/0/Pictures/0cccb0f1-375b-44b8-b15b-4625536a8d63.jpg

Axios Call

const addProduct = async product => {  try {    var prod = await axios({      method: 'post',      url: baseURL +'addProduct',      data: product,      headers: {'content-type': `multipart/form-data; boundary=${product._boundary}`,    Accept: 'application/json',  },      },    });    return prod;  } catch (err) {    throw err;  }};

after alot of trials i understand that in bodyFormData even i write any kind of json object

const oj = {          name: 'a',          c: 8,        }bodyFormData.append('image', obj  );

it throws me the same error

[Error: Network Error]

Kindly please drop the best possible solution for the problem

Thank you for your precious time.


Viewing all articles
Browse latest Browse all 30350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>