简体   繁体   中英

Why does my fetch function result in a 'Network request failed' in Expo?

I want to store videos along with their thumbnails (expo-video-thumbnails) using Expo with a Firebase back-end. I can pass videos through my fetch function but whenever I try doing the same with the thumbnails I catch a 'Network request failed' error.

I've been trying to fix this for a while now without success. Here is my code - I'd gladly appreciate some help with this!

    export const saveMediaToStorage = (media, path) => new Promise((resolve, reject) => {
       const fileRef = firebase.storage().ref().child(path)

       fetch(media)
           .then(response => response.blob())
           .then(blob => fileRef.put(blob))
           .then(task => task.ref.getDownloadURL())
           .then(downloadUrl => resolve(downloadUrl))
           // .catch(() => reject())
           .catch((e) => {console.error(e)})
})

Edit: I am using an Android Emulator

Does your link use https? or http? you might want to use https?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM