Am using FormData() and Fetch() to Post and Image File to My Server After Tacking A picture on Android.
am using a public IP not posting to my localhost or anything and not using HTTPS, also using Genymotion Emulator.
My Code :
var fd = new FormData();
fd.append('image', {path:'file:///'});
fetch(UPLOAD_URI,{
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data',
},
body: fd
}).then(response => {
console.log("image uploaded")
}).catch(err => {
console.log(err)
})
Error Returned In the catch as the param err:
TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (fetch.js:441)
at XMLHttpRequest.dispatchEvent (event-target.js:172)
at XMLHttpRequest.setReadyState (XMLHttpRequest.js:542)
at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:378)
at XMLHttpRequest.js:482
at RCTDeviceEventEmitter.emit (EventEmitter.js:181)
at MessageQueue.__callFunction (MessageQueue.js:236)
at MessageQueue.js:108
at guard (MessageQueue.js:46)
at MessageQueue.callFunctionReturnFlushedQueue (MessageQueue.js:107)
Is there some kind of permissions that am missing , whats the problem ?
Cheers,