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

ReactNative typescript: Axios is not allowing to pass file data FormData to upload file

$
0
0

I am building a Mobile application using ReactNative and TypeScript. I am trying to upload file using Axios so that I need to make multipart/form-data request. In javascript I can pass the file data to the form data request like this.

formData.append(`image_file`, {                uri: form.image_file.path,                name: form.image_file.filename,                type: form.image_file.mime            });

Now, I am trying to do the same for TypeScript. But when I pass the same object in the TypeScript, I am getting the following compilation error.

enter image description here

enter image description here

So that I had to cast the object into any type as follow.

enter image description here

How can I fix that error without casting the object into any because I am not a fan of using any type.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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