3

I get the error RangeError Failed to construct 'Response': The status provided (0) is outside the range [200, 599].

This is the code

for (let i = 0; i < images.length; i++) {
   
        const fileName = Date.now() + i;

        const storageRef = ref(
          storage,
          `images/clinics/${auth.currentUser.uid}/${fileName}`
        );
        clinicImag.push({img:`${fileName}`, isMainImg: true)
        const img = await fetch(images[i].img);
        const bytes = await img.blob();
        const metadata = {
          contentType: 'image/jpeg',
        };

        
        let uri = await uploadBytes(storageRef, bytes, metadata).then( (snapshot) =>{
          return getDownloadURL(snapshot.ref)
         
        });
        
        clinicImagesURI.push({img:`${uri}`, isMainImg: images[i].isMainImg})
      
    
      }
    

The error comes from const img = await fetch(images[i].img);

The images[i].img is an uri from expo image picker

What would solve this? I m stuck for days

If i remove the line with const img = await fetch(images[i].img) I don t get the error

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Facing the same issue in bare react native as well, seems like the issue started appearing after I changed the android targetSDK version to 33 to aomply with new Google Play rules. – FutureJJ Jul 25 '23 at 09:46
  • Why does this question have one downvote? Downvoting a question/answer without any apparent reason is a bad practice. This question has one upvote though making the total number of votes 0 at the time of this comment. – FutureJJ Jul 26 '23 at 01:22
  • 2
    Does this answer your question? [fetching loacal files is causing staus 0 error in react native (expo) app](https://stackoverflow.com/questions/76754693/fetching-loacal-files-is-causing-staus-0-error-in-react-native-expo-app) – FutureJJ Jul 29 '23 at 05:45

1 Answers1

0

I had the same problem and needed to do 2 things to solve it.

  1. replaced fetch with XMLHttpReqest as found in this answer.

  2. replaced uploadBytes with uploadBytesResumable