Im using Expo for React Native and it's Image Picker. I would like to send my image file that I get from my phone as binary like I send in Postman as in the picture below.
Im using Axios for API operations.
I tried to send the base64 data or fetch the image from it's uri and send it's blob. Both none of them worked.
This is my axios post request template.
post: async (url, data) => {
const token = await getToken("token")
const res = await instance(token).post(url, data).catch((error) => {
console.log(error.response)
return error.response.data.message;
});
console.log(res.data)
return res.data;
},
And this is my Imagepicker code
const pickImage = async () => {
let result = await ImagePicker.launchImageLibraryAsync({
allowsEditing: true,
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsMultipleSelection: false,
aspect: [4, 2],
base64: true,
});
if (!result.canceled) {
dispatch(authActions.uploadProfileImageRequest(result.assets[0].base64))
}
};
How can I accomplish to send data file as I did in Postman?