Hello,
I am trying to upload an image to my server but I get the following error :
Error processing request body: Error Domain=ABI36_0_0RCTErrorDomain Code=0 “Invalid request token.” UserInfo={NSlocalizedDescription=Invalid request token.}
Here is my code :
let fileName = imagePath.split("/").pop();
const photo = {
uri: imagePath,
type: "image/jpeg",
name: fileName
};
const formData = new FormData();
formData.append("photo", photo);
const options = {
method: "POST",
body: formData,
headers: {
Accept: "application/json",
"Content-Type": "multipart/form-data"
}
};
fetch(serverEndpoint, options);
I am using :
- Expo 36
- Testing on IOS device
I tried :
- to downgrade to version 35 but still get the same issue (error message is then “ABI35_0_0…”)
- to remove the “file://” prefix in the uri, but I still get the same error.
It works fine when replacing the “photo” by a text file, but the problem only occurs when attaching an image.
Would you have a solution or a workaround for this issue please ?
I just want to upload an image to my server.
Thanks !