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

[Unhandled promise rejection: TypeError: Network request failed]

$
0
0

I am uploading photo with expo-image-picker and it works okay for IOS but for android it shows the following error message [Unhandled promise rejection: TypeError: Network request failed].

The code is as below

How I set the image values:

 setImage({        uri: result.uri,        name: `photo.${fileType}`,        type:`application/${fileType}`,      });

How I append it to formdata

 formData.append('file', {      uri: image.uri,      name: image.name,      type: image.type,    });

How I send the request to backend:

await axios.fetch("/upload", {   formData,   method: 'POST',   headers: {"Content-Type": `application/json`,    },});

Viewing all articles
Browse latest Browse all 6290

Trending Articles



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