iOS Development

ios – Getting immutable object error when calling fetch() from React Native

I’m attempting to name the Fetch API to add a file and related knowledge from a React Native app for iOS. The add succeeds, however I get an error that pops up with the next message:

Error: You tried to set the important thing _i with the worth 1 on an object that’s meant to be immutable and has been frozen., js engine: hermes

The code I’m utilizing is under. What’s inflicting this error?

perform UploadScreen({route,navigation}){
  const {videoFile,cellphone,drugName,timeToTake,caregiverPhoneNumber} = route.params;
  const handleUpload = async () => {
    strive{
    console.log('In handleUpload');
    const videoPath = videoFile;
    const videoData = readFile(videoPath,'base64');
    const videoUri = 'file://' + videoPath;
    const video = {
      url: videoUri,
      sort: 'video/mp4',
      identify: 'video.mp4',
    };
    const formData = new FormData();
    formData.append('file',{uri: videoPath, identify: 'video.mp4', sort:'video/mp4', knowledge:videoData});
    formData.append('sender',caregiverPhoneNumber);
    formData.append('recipient',cellphone);
    formData.append('timeToTake',timeToTake);
    formData.append('drugName',drugName);
    console.log('earlier than fetch');
    
    const response = await fetch('http://10.0.0.7/MedicationAdherenceVideoServer/UploadVideoWithData.ashx',{
      methodology:'POST',
      physique: formData,
    });
    const responseData = await response.textual content();
    console.log(responseData);
    Alert.alert('Remedy file uploaded');
    
    navigation.navigate('Residence',{phoneNumber:caregiverPhoneNumber});
  }
  catch (error){
    console.log(error.message);
    Alert.alert('Error',error.message);
    navigation.navigate('Residence',{phoneNumber:caregiverPhoneNumber});
  }
  };
  useEffect(() => {
    console.log('In UploadScreen');
    handleUpload();
  },[]);
}

I used to be anticipating the fetch() name to succeed with no errors. The fetch name does succeed within the sense that the information and video file are uploaded, however I do get an error message.

I’ve tried each the .then()/.catch() sample for guarantees in addition to the async/await sample.

Credit: www.ismmailgsm.com

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button