I am getting this warning when I run my react-native mobile app. I try to upload photo with react-native-image-picker to firebase (in the storage) and save the url of this photo in the firebase (database). The upload is made succefully but when the program try to save the url in database the app give a warning: "Possible Unhandled Promise Rejection: Can't find variable: listeners". Below is my code:
ImagePicker.showImagePicker(options, (response) => {
let filePath = response.path;
let fileName = this.props.imageName;
let rnfbURI = RNFetchBlob.wrap(filePath);
Blob
.build(rnfbURI, { type : 'image/png;'})
.then((blob) => {
// upload image using Firebase SDK
this.props.bdd.storage()
.ref('images')
.child(fileName)
.put(blob, { contentType : 'image/jpg' })
.then((snapshot) => {
console.log('Uploaded', snapshot.totalBytes, 'bytes.');
console.log(snapshot.metadata);
console.log('downlo='+snapshot.metadata.downloadURLs[0]);
var ref = this.props.bdd.database().ref('promotions/'+ fileName);
alert(snapshot.metadata.downloadURLs[0]);
ref.update({
image_url:snapshot.metadata.downloadURLs[0]
});
}).catch(function(error) {
console.error('Upload failed:', error);
});
})
});
}
I think it is caused because you are not making a complete promise, usually it looks like this: