I recently encountered an issue with the expo-image-picker
and axios 0.26.1
. It seems that the use of formData
in axios
version 0.26.1 is not functioning properly, as data is not being sent to the api
https://i.sstatic.net/Bvaou.png
As a workaround, I decided to downgrade axios
to version 0.24.0. However, this solution resulted in an error when trying to send formData on an Android emulator.
Error: Network Error
This is how the formData looks like:
https://i.sstatic.net/Knbwb.png
export const sendRequest = (url, response, method, formData) => {
return axios({
url,
method,
data: method !== "get" ? formData : null,
headers: {
Authorization: `Bearer ${response.data.access}`,
transformRequest: (data, headers) => {
return formData;
},
},
});
const formData = new FormData();
const imageUri = image.value.uri;
const newImageUri = "file:///" + imageUri.split("file:/").join("");
formData.append("photo", {
uri: newImageUri,
type: mime.getType(newImageUri),
name: newImageUri.split("/").pop(),
});
data.append("title", title);
If anyone has experience with this issue, your help would be greatly appreciated!